diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-08-16 14:10:05 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-08-16 14:10:05 +0200 |
commit | 8004aa77212eed6dd1142c713275a4e0c5d0c40e (patch) | |
tree | f9d0b1589dd354ddbe55f7738f6df95c75fae29f /lib/private | |
parent | 604c1752845df068a7dd5d168abfbfc04065ac3f (diff) | |
download | nextcloud-server-8004aa77212eed6dd1142c713275a4e0c5d0c40e.tar.gz nextcloud-server-8004aa77212eed6dd1142c713275a4e0c5d0c40e.zip |
Make DisplayNameCache return null if user doesn't exists
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/User/DisplayNameCache.php | 4 | ||||
-rw-r--r-- | lib/private/User/LazyUser.php | 2 | ||||
-rw-r--r-- | lib/private/User/Manager.php | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/lib/private/User/DisplayNameCache.php b/lib/private/User/DisplayNameCache.php index 22a79863e49..5d1cc8940d7 100644 --- a/lib/private/User/DisplayNameCache.php +++ b/lib/private/User/DisplayNameCache.php @@ -47,7 +47,7 @@ class DisplayNameCache implements IEventListener { $this->userManager = $userManager; } - public function getDisplayName(string $userId) { + public function getDisplayName(string $userId): ?string { if (isset($this->cache[$userId])) { return $this->cache[$userId]; } @@ -61,7 +61,7 @@ class DisplayNameCache implements IEventListener { if ($user) { $displayName = $user->getDisplayName(); } else { - $displayName = $userId; + $displayName = null; } $this->cache[$userId] = $displayName; $this->memCache->set($userId, $displayName, 60 * 10); // 10 minutes diff --git a/lib/private/User/LazyUser.php b/lib/private/User/LazyUser.php index 118dd3d0699..096578b8f37 100644 --- a/lib/private/User/LazyUser.php +++ b/lib/private/User/LazyUser.php @@ -51,7 +51,7 @@ class LazyUser implements IUser { } public function getDisplayName() { - return $this->userManager->getDisplayName($this->uid); + return $this->userManager->getDisplayName($this->uid) ?? $this->uid; } public function setDisplayName($displayName) { diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index 55ac663f3ec..be5151313c4 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -188,7 +188,7 @@ class Manager extends PublicEmitter implements IUserManager { return null; } - public function getDisplayName(string $uid): string { + public function getDisplayName(string $uid): ?string { return $this->displayNameCache->getDisplayName($uid); } |