Signed-off-by: Carl Schwan <carl@carlschwan.eu>tags/v25.0.0beta2
@@ -170,7 +170,7 @@ class Cache extends CacheJail { | |||
private function getOwnerDisplayName() { | |||
if (!$this->ownerDisplayName) { | |||
$uid = $this->storage->getOwner(''); | |||
$this->ownerDisplayName = $this->displayNameCache->getDisplayName($uid); | |||
$this->ownerDisplayName = $this->displayNameCache->getDisplayName($uid) ?? $uid; | |||
} | |||
return $this->ownerDisplayName; | |||
} |
@@ -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 |
@@ -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) { |
@@ -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); | |||
} | |||
@@ -87,13 +87,11 @@ interface IUserManager { | |||
/** | |||
* Get the display name of a user | |||
* | |||
* Note that this will return the uid if the user is not found instead of throwing an exception | |||
* | |||
* @param string $uid | |||
* @return string | |||
* @return string|null | |||
* @since 25.0.0 | |||
*/ | |||
public function getDisplayName(string $uid): string; | |||
public function getDisplayName(string $uid): ?string; | |||
/** | |||
* check if a user exists |