summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorChristoph Wurst <ChristophWurst@users.noreply.github.com>2021-06-17 18:17:28 +0200
committerGitHub <noreply@github.com>2021-06-17 18:17:28 +0200
commitb73f40eabbfb3e7941b5628b7243b58211e07d58 (patch)
tree735f80d79f1bec875bdd20c0bdf820abf11e45f4 /apps
parent18ff2612a1a7908b613490a38b6d49ee2dc18a19 (diff)
parent2690481cbad009b74292fdfbd028fc8b5b01a394 (diff)
downloadnextcloud-server-b73f40eabbfb3e7941b5628b7243b58211e07d58.tar.gz
nextcloud-server-b73f40eabbfb3e7941b5628b7243b58211e07d58.zip
Merge pull request #24318 from nextcloud/techdebt/noid/remove-oc_user-getDisplayName
Use proper methods for display name retrieval
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/Cache.php24
-rw-r--r--apps/files_sharing/lib/SharedStorage.php7
2 files changed, 20 insertions, 11 deletions
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php
index 25e92d23962..8729426221b 100644
--- a/apps/files_sharing/lib/Cache.php
+++ b/apps/files_sharing/lib/Cache.php
@@ -38,6 +38,7 @@ use OCP\Files\Search\ISearchBinaryOperator;
use OCP\Files\Search\ISearchComparison;
use OCP\Files\Search\ISearchOperator;
use OCP\Files\StorageNotAvailableException;
+use OCP\IUserManager;
/**
* Metadata cache for shared files
@@ -45,15 +46,12 @@ use OCP\Files\StorageNotAvailableException;
* don't use this class directly if you need to get metadata, use \OC\Files\Filesystem::getFileInfo instead
*/
class Cache extends CacheJail {
- /**
- * @var \OCA\Files_Sharing\SharedStorage
- */
+ /** @var \OCA\Files_Sharing\SharedStorage */
private $storage;
-
- /**
- * @var ICacheEntry
- */
+ /** @var ICacheEntry */
private $sourceRootInfo;
+ /** @var IUserManager */
+ private $userManager;
private $rootUnchanged = true;
@@ -63,11 +61,11 @@ class Cache extends CacheJail {
/**
* @param \OCA\Files_Sharing\SharedStorage $storage
- * @param ICacheEntry $sourceRootInfo
*/
- public function __construct($storage, ICacheEntry $sourceRootInfo) {
+ public function __construct($storage, ICacheEntry $sourceRootInfo, IUserManager $userManager) {
$this->storage = $storage;
$this->sourceRootInfo = $sourceRootInfo;
+ $this->userManager = $userManager;
$this->numericId = $sourceRootInfo->getStorageId();
parent::__construct(
@@ -174,7 +172,13 @@ class Cache extends CacheJail {
private function getOwnerDisplayName() {
if (!$this->ownerDisplayName) {
- $this->ownerDisplayName = \OC_User::getDisplayName($this->storage->getOwner(''));
+ $uid = $this->storage->getOwner('');
+ $user = $this->userManager->get($uid);
+ if ($user) {
+ $this->ownerDisplayName = $user->getDisplayName();
+ } else {
+ $this->ownerDisplayName = $uid;
+ }
}
return $this->ownerDisplayName;
}
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php
index 662c5ad3651..f4a525ce871 100644
--- a/apps/files_sharing/lib/SharedStorage.php
+++ b/apps/files_sharing/lib/SharedStorage.php
@@ -43,6 +43,7 @@ use OCP\Files\Cache\ICacheEntry;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\IDisableEncryptionStorage;
use OCP\Files\Storage\IStorage;
+use OCP\IUserManager;
use OCP\Lock\ILockingProvider;
use OCP\Share\IShare;
@@ -385,7 +386,11 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
return new FailedCache();
}
- $this->cache = new \OCA\Files_Sharing\Cache($storage, $sourceRoot, $this->superShare);
+ $this->cache = new \OCA\Files_Sharing\Cache(
+ $storage,
+ $sourceRoot,
+ \OC::$server->get(IUserManager::class)
+ );
return $this->cache;
}