diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Files/Cache/Cache.php | 2 | ||||
-rw-r--r-- | lib/private/Files/Cache/CacheEntry.php | 6 | ||||
-rw-r--r-- | lib/private/Memcache/Factory.php | 16 |
3 files changed, 13 insertions, 11 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index bf459b2ff86..20b662e8d81 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -149,7 +149,7 @@ class Cache implements ICache { * get the stored metadata of a file or folder * * @param string | int $file either the path of a file or folder or the file id for a file or folder - * @return ICacheEntry|false the cache entry as array of false if the file is not found in the cache + * @return ICacheEntry|false the cache entry as array or false if the file is not found in the cache */ public function get($file) { $query = $this->getQueryBuilder(); diff --git a/lib/private/Files/Cache/CacheEntry.php b/lib/private/Files/Cache/CacheEntry.php index 3c93296ff62..ce9df2823c8 100644 --- a/lib/private/Files/Cache/CacheEntry.php +++ b/lib/private/Files/Cache/CacheEntry.php @@ -114,15 +114,15 @@ class CacheEntry implements ICacheEntry { } public function getMetadataEtag(): ?string { - return $this->data['metadata_etag']; + return $this->data['metadata_etag'] ?? null; } public function getCreationTime(): ?int { - return $this->data['creation_time']; + return $this->data['creation_time'] ?? null; } public function getUploadTime(): ?int { - return $this->data['upload_time']; + return $this->data['upload_time'] ?? null; } public function getData() { diff --git a/lib/private/Memcache/Factory.php b/lib/private/Memcache/Factory.php index 604f764c03c..788a7c2e8c9 100644 --- a/lib/private/Memcache/Factory.php +++ b/lib/private/Memcache/Factory.php @@ -73,16 +73,17 @@ class Factory implements ICacheFactory { */ public function __construct(string $globalPrefix, LoggerInterface $logger, IProfiler $profiler, ?string $localCacheClass = null, ?string $distributedCacheClass = null, ?string $lockingCacheClass = null, string $logFile = '') { - $this->logger = $logger; $this->logFile = $logFile; $this->globalPrefix = $globalPrefix; if (!$localCacheClass) { $localCacheClass = self::NULL_CACHE; } + $localCacheClass = ltrim($localCacheClass, '\\'); if (!$distributedCacheClass) { $distributedCacheClass = $localCacheClass; } + $distributedCacheClass = ltrim($distributedCacheClass, '\\'); $missingCacheMessage = 'Memcache {class} not available for {use} cache'; $missingCacheHint = 'Is the matching PHP module installed and enabled?'; @@ -97,9 +98,10 @@ class Factory implements ICacheFactory { ]), $missingCacheHint); } if (!($lockingCacheClass && class_exists($lockingCacheClass) && $lockingCacheClass::isAvailable())) { - // don't fallback since the fallback might not be suitable for storing lock + // don't fall back since the fallback might not be suitable for storing lock $lockingCacheClass = self::NULL_CACHE; } + $lockingCacheClass = ltrim($lockingCacheClass, '\\'); $this->localCacheClass = $localCacheClass; $this->distributedCacheClass = $distributedCacheClass; @@ -116,7 +118,7 @@ class Factory implements ICacheFactory { public function createLocking(string $prefix = ''): IMemcache { assert($this->lockingCacheClass !== null); $cache = new $this->lockingCacheClass($this->globalPrefix . '/' . $prefix); - if ($this->profiler->isEnabled() && $this->lockingCacheClass === '\OC\Memcache\Redis') { + if ($this->lockingCacheClass === Redis::class && $this->profiler->isEnabled()) { // We only support the profiler with Redis $cache = new ProfilerWrapperCache($cache, 'Locking'); $this->profiler->add($cache); @@ -138,7 +140,7 @@ class Factory implements ICacheFactory { public function createDistributed(string $prefix = ''): ICache { assert($this->distributedCacheClass !== null); $cache = new $this->distributedCacheClass($this->globalPrefix . '/' . $prefix); - if ($this->profiler->isEnabled() && $this->distributedCacheClass === '\OC\Memcache\Redis') { + if ($this->distributedCacheClass === Redis::class && $this->profiler->isEnabled()) { // We only support the profiler with Redis $cache = new ProfilerWrapperCache($cache, 'Distributed'); $this->profiler->add($cache); @@ -160,7 +162,7 @@ class Factory implements ICacheFactory { public function createLocal(string $prefix = ''): ICache { assert($this->localCacheClass !== null); $cache = new $this->localCacheClass($this->globalPrefix . '/' . $prefix); - if ($this->profiler->isEnabled() && $this->localCacheClass === '\OC\Memcache\Redis') { + if ($this->localCacheClass === Redis::class && $this->profiler->isEnabled()) { // We only support the profiler with Redis $cache = new ProfilerWrapperCache($cache, 'Local'); $this->profiler->add($cache); @@ -179,7 +181,7 @@ class Factory implements ICacheFactory { * @return bool */ public function isAvailable(): bool { - return ($this->distributedCacheClass !== self::NULL_CACHE); + return $this->distributedCacheClass !== self::NULL_CACHE; } /** @@ -197,6 +199,6 @@ class Factory implements ICacheFactory { * @return bool */ public function isLocalCacheAvailable(): bool { - return ($this->localCacheClass !== self::NULL_CACHE); + return $this->localCacheClass !== self::NULL_CACHE; } } |