]> source.dussan.org Git - nextcloud-server.git/commitdiff
reuse dependencies from wrapped cache
authorRobin Appelman <robin@icewind.nl>
Tue, 15 Aug 2023 14:44:23 +0000 (16:44 +0200)
committerRobin Appelman <robin@icewind.nl>
Thu, 7 Sep 2023 14:22:00 +0000 (16:22 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Cache/Wrapper/CacheWrapper.php

index 6479ea793b000eb33c74e2ba485beccc82db3a79..39a78f31343c370f1a044a1c64bbf6ef7022e50f 100644 (file)
@@ -33,8 +33,10 @@ use OC\Files\Cache\Cache;
 use OC\Files\Cache\QuerySearchHelper;
 use OCP\Files\Cache\ICache;
 use OCP\Files\Cache\ICacheEntry;
+use OCP\Files\IMimeTypeLoader;
 use OCP\Files\Search\ISearchOperator;
 use OCP\Files\Search\ISearchQuery;
+use OCP\IDBConnection;
 
 class CacheWrapper extends Cache {
        /**
@@ -47,9 +49,15 @@ class CacheWrapper extends Cache {
         */
        public function __construct($cache) {
                $this->cache = $cache;
-               $this->mimetypeLoader = \OC::$server->getMimeTypeLoader();
-               $this->connection = \OC::$server->getDatabaseConnection();
-               $this->querySearchHelper = \OC::$server->get(QuerySearchHelper::class);
+               if ($cache instanceof Cache) {
+                       $this->mimetypeLoader = $cache->mimetypeLoader;
+                       $this->connection = $cache->connection;
+                       $this->querySearchHelper = $cache->querySearchHelper;
+               } else {
+                       $this->mimetypeLoader = \OC::$server->get(IMimeTypeLoader::class);
+                       $this->connection = \OC::$server->get(IDBConnection::class);
+                       $this->querySearchHelper = \OC::$server->get(QuerySearchHelper::class);
+               }
        }
 
        protected function getCache() {