Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ protected function formatCacheEntry($entry, $path = null) {
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;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/private/User/DisplayNameCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(ICacheFactory $cacheFactory, IUserManager $userManag
$this->userManager = $userManager;
}

public function getDisplayName(string $userId) {
public function getDisplayName(string $userId): ?string {
if (isset($this->cache[$userId])) {
return $this->cache[$userId];
}
Expand All @@ -61,7 +61,7 @@ public function getDisplayName(string $userId) {
if ($user) {
$displayName = $user->getDisplayName();
} else {
$displayName = $userId;
$displayName = null;
}
$this->cache[$userId] = $displayName;
$this->memCache->set($userId, $displayName, 60 * 10); // 10 minutes
Expand Down
2 changes: 1 addition & 1 deletion lib/private/User/LazyUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getUID() {
}

public function getDisplayName() {
return $this->userManager->getDisplayName($this->uid);
return $this->userManager->getDisplayName($this->uid) ?? $this->uid;
}

public function setDisplayName($displayName) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/User/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function get($uid) {
return null;
}

public function getDisplayName(string $uid): string {
public function getDisplayName(string $uid): ?string {
return $this->displayNameCache->getDisplayName($uid);
}

Expand Down
6 changes: 2 additions & 4 deletions lib/public/IUserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ public function get($uid);
/**
* 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
Expand Down