aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2023-06-03 00:37:35 +0200
committerAndy Scherzinger <info@andy-scherzinger.de>2024-02-27 14:22:25 +0100
commitbdd37562f078cc077c34ab03919b8df00ee69a7a (patch)
tree488887a986dfbd28794007d88382046750bd0ee5
parent250084f8b913e326e20ccc60c86091beab0a6524 (diff)
downloadnextcloud-server-fix/noid/ldap-displayname-cached.tar.gz
nextcloud-server-fix/noid/ldap-displayname-cached.zip
fix: do not fetch LDAP display name all the timefix/noid/ldap-displayname-cached
- use cache and rely on background update mechanism - with ajax cron it will still run - core User must not cache uid as displayname to address edge case (early announcement with displayname not ready) Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
-rw-r--r--apps/user_ldap/lib/User_LDAP.php41
-rw-r--r--lib/private/User/User.php2
2 files changed, 3 insertions, 40 deletions
diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php
index d787bfea4d4..9c7c4bca93b 100644
--- a/apps/user_ldap/lib/User_LDAP.php
+++ b/apps/user_ldap/lib/User_LDAP.php
@@ -461,7 +461,7 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I
/**
* get display name of the user
* @param string $uid user ID of the user
- * @return string|false display name
+ * @return ?string|false display name
*/
public function getDisplayName($uid) {
if ($this->userPluginManager->implementsActions(Backend::GET_DISPLAYNAME)) {
@@ -472,44 +472,7 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I
return false;
}
- $cacheKey = 'getDisplayName'.$uid;
- if (!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) {
- return $displayName;
- }
-
- //Check whether the display name is configured to have a 2nd feature
- $additionalAttribute = $this->access->connection->ldapUserDisplayName2;
- $displayName2 = '';
- if ($additionalAttribute !== '') {
- $displayName2 = $this->access->readAttribute(
- $this->access->username2dn($uid),
- $additionalAttribute);
- }
-
- $displayName = $this->access->readAttribute(
- $this->access->username2dn($uid),
- $this->access->connection->ldapUserDisplayName);
-
- if ($displayName && (count($displayName) > 0)) {
- $displayName = $displayName[0];
-
- if (is_array($displayName2)) {
- $displayName2 = count($displayName2) > 0 ? $displayName2[0] : '';
- }
-
- $user = $this->access->userManager->get($uid);
- if ($user instanceof User) {
- $displayName = $user->composeAndStoreDisplayName($displayName, $displayName2);
- $this->access->connection->writeToCache($cacheKey, $displayName);
- }
- if ($user instanceof OfflineUser) {
- /** @var OfflineUser $user*/
- $displayName = $user->getDisplayName();
- }
- return $displayName;
- }
-
- return null;
+ return $this->ocConfig->getUserValue($uid, 'user_ldap', 'displayName', null);
}
/**
diff --git a/lib/private/User/User.php b/lib/private/User/User.php
index 580c590e6eb..a53d84794fd 100644
--- a/lib/private/User/User.php
+++ b/lib/private/User/User.php
@@ -145,7 +145,7 @@ class User implements IUser {
if (!empty($displayName)) {
$this->displayName = $displayName;
} else {
- $this->displayName = $this->uid;
+ return $this->uid;
}
}
return $this->displayName;