diff options
Diffstat (limited to 'apps/files_sharing/lib/Cache.php')
-rw-r--r-- | apps/files_sharing/lib/Cache.php | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index c49bebaef62..9f11431008f 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -33,6 +33,7 @@ use OC\Files\Cache\Wrapper\CacheJail; use OC\Files\Search\SearchBinaryOperator; use OC\Files\Search\SearchComparison; use OC\Files\Storage\Wrapper\Jail; +use OC\User\DisplayNameCache; use OCP\Files\Cache\ICacheEntry; use OCP\Files\Search\ISearchBinaryOperator; use OCP\Files\Search\ISearchComparison; @@ -47,27 +48,22 @@ use OCP\IUserManager; * 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 SharedStorage */ private $storage; - /** @var ICacheEntry */ - private $sourceRootInfo; - /** @var IUserManager */ - private $userManager; - - private $rootUnchanged = true; - - private $ownerDisplayName; - + private ICacheEntry $sourceRootInfo; + private bool $rootUnchanged = true; + private ?string $ownerDisplayName = null; private $numericId; + private DisplayNameCache $displayNameCache; /** - * @param \OCA\Files_Sharing\SharedStorage $storage + * @param SharedStorage $storage */ - public function __construct($storage, ICacheEntry $sourceRootInfo, IUserManager $userManager) { + public function __construct($storage, ICacheEntry $sourceRootInfo, DisplayNameCache $displayNameCache) { $this->storage = $storage; $this->sourceRootInfo = $sourceRootInfo; - $this->userManager = $userManager; $this->numericId = $sourceRootInfo->getStorageId(); + $this->displayNameCache = $displayNameCache; parent::__construct( null, @@ -173,22 +169,8 @@ class Cache extends CacheJail { private function getOwnerDisplayName() { if (!$this->ownerDisplayName) { - /** @var ICacheFactory $cacheFactory */ - $cacheFactory = \OC::$server->get(ICacheFactory::class); - $memcache = $cacheFactory->createLocal('share_owner_name'); $uid = $this->storage->getOwner(''); - $cached = $memcache->get($uid); - if ($cached) { - $this->ownerDisplayName = $cached; - } else { - $user = $this->userManager->get($uid); - if ($user) { - $this->ownerDisplayName = $user->getDisplayName(); - } else { - $this->ownerDisplayName = $uid; - } - $memcache->set($uid, $this->ownerDisplayName, 60 * 60); - } + $this->ownerDisplayName = $this->displayNameCache->getDisplayName($uid); } return $this->ownerDisplayName; } |