diff options
Diffstat (limited to 'lib/private/Files/Cache')
-rw-r--r-- | lib/private/Files/Cache/Cache.php | 140 | ||||
-rw-r--r-- | lib/private/Files/Cache/CacheEntry.php | 4 | ||||
-rw-r--r-- | lib/private/Files/Cache/CacheQueryBuilder.php | 9 | ||||
-rw-r--r-- | lib/private/Files/Cache/FailedCache.php | 9 | ||||
-rw-r--r-- | lib/private/Files/Cache/QuerySearchHelper.php | 119 | ||||
-rw-r--r-- | lib/private/Files/Cache/Wrapper/CacheJail.php | 127 | ||||
-rw-r--r-- | lib/private/Files/Cache/Wrapper/CacheWrapper.php | 50 |
7 files changed, 215 insertions, 243 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 0e677e8a5b9..b93fcd6af7f 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -40,7 +40,8 @@ namespace OC\Files\Cache; use Doctrine\DBAL\Exception\UniqueConstraintViolationException; -use OCP\DB\IResult; +use OC\Files\Search\SearchComparison; +use OC\Files\Search\SearchQuery; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Cache\CacheEntryInsertedEvent; @@ -52,6 +53,7 @@ use OCP\Files\Cache\ICache; use OCP\Files\Cache\ICacheEntry; use OCP\Files\FileInfo; use OCP\Files\IMimeTypeLoader; +use OCP\Files\Search\ISearchComparison; use OCP\Files\Search\ISearchQuery; use OCP\Files\Storage\IStorage; use OCP\IDBConnection; @@ -118,15 +120,19 @@ class Cache implements ICache { $this->mimetypeLoader = \OC::$server->getMimeTypeLoader(); $this->connection = \OC::$server->getDatabaseConnection(); $this->eventDispatcher = \OC::$server->get(IEventDispatcher::class); - $this->querySearchHelper = new QuerySearchHelper($this->mimetypeLoader); + $this->querySearchHelper = new QuerySearchHelper( + $this->mimetypeLoader, + $this->connection, + \OC::$server->getSystemConfig(), + \OC::$server->getLogger() + ); } protected function getQueryBuilder() { return new CacheQueryBuilder( $this->connection, \OC::$server->getSystemConfig(), - \OC::$server->getLogger(), - $this + \OC::$server->getLogger() ); } @@ -153,7 +159,7 @@ class Cache implements ICache { // normalize file $file = $this->normalize($file); - $query->whereStorageId() + $query->whereStorageId($this->getNumericStorageId()) ->wherePath($file); } else { //file id $query->whereFileId($file); @@ -482,7 +488,7 @@ class Cache implements ICache { $query = $this->getQueryBuilder(); $query->select('fileid') ->from('filecache') - ->whereStorageId() + ->whereStorageId($this->getNumericStorageId()) ->wherePath($file); $result = $query->execute(); @@ -718,7 +724,7 @@ class Cache implements ICache { public function clear() { $query = $this->getQueryBuilder(); $query->delete('filecache') - ->whereStorageId(); + ->whereStorageId($this->getNumericStorageId()); $query->execute(); $query = $this->connection->getQueryBuilder(); @@ -746,7 +752,7 @@ class Cache implements ICache { $query = $this->getQueryBuilder(); $query->select('size') ->from('filecache') - ->whereStorageId() + ->whereStorageId($this->getNumericStorageId()) ->wherePath($file); $result = $query->execute(); @@ -775,37 +781,8 @@ class Cache implements ICache { * @return ICacheEntry[] an array of cache entries where the name matches the search pattern */ public function search($pattern) { - // normalize pattern - $pattern = $this->normalize($pattern); - - if ($pattern === '%%') { - return []; - } - - $query = $this->getQueryBuilder(); - $query->selectFileCache() - ->whereStorageId() - ->andWhere($query->expr()->iLike('name', $query->createNamedParameter($pattern))); - - $result = $query->execute(); - $files = $result->fetchAll(); - $result->closeCursor(); - - return array_map(function (array $data) { - return self::cacheEntryFromData($data, $this->mimetypeLoader); - }, $files); - } - - /** - * @param IResult $result - * @return CacheEntry[] - */ - private function searchResultToCacheEntries(IResult $result): array { - $files = $result->fetchAll(); - - return array_map(function (array $data) { - return self::cacheEntryFromData($data, $this->mimetypeLoader); - }, $files); + $operator = new SearchComparison(ISearchComparison::COMPARE_LIKE, 'name', $pattern); + return $this->searchQuery(new SearchQuery($operator, 0, 0, [], null)); } /** @@ -816,71 +793,16 @@ class Cache implements ICache { * @return ICacheEntry[] an array of cache entries where the mimetype matches the search */ public function searchByMime($mimetype) { - $mimeId = $this->mimetypeLoader->getId($mimetype); - - $query = $this->getQueryBuilder(); - $query->selectFileCache() - ->whereStorageId(); - - if (strpos($mimetype, '/')) { - $query->andWhere($query->expr()->eq('mimetype', $query->createNamedParameter($mimeId, IQueryBuilder::PARAM_INT))); + if (strpos($mimetype, '/') === false) { + $operator = new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mimetype . '/%'); } else { - $query->andWhere($query->expr()->eq('mimepart', $query->createNamedParameter($mimeId, IQueryBuilder::PARAM_INT))); + $operator = new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', $mimetype); } - - $result = $query->execute(); - $files = $result->fetchAll(); - $result->closeCursor(); - - return array_map(function (array $data) { - return self::cacheEntryFromData($data, $this->mimetypeLoader); - }, $files); + return $this->searchQuery(new SearchQuery($operator, 0, 0, [], null)); } public function searchQuery(ISearchQuery $searchQuery) { - $builder = $this->getQueryBuilder(); - - $query = $builder->selectFileCache('file'); - - $query->whereStorageId(); - - if ($this->querySearchHelper->shouldJoinTags($searchQuery->getSearchOperation())) { - $user = $searchQuery->getUser(); - if ($user === null) { - throw new \InvalidArgumentException("Searching by tag requires the user to be set in the query"); - } - $query - ->innerJoin('file', 'vcategory_to_object', 'tagmap', $builder->expr()->eq('file.fileid', 'tagmap.objid')) - ->innerJoin('tagmap', 'vcategory', 'tag', $builder->expr()->andX( - $builder->expr()->eq('tagmap.type', 'tag.type'), - $builder->expr()->eq('tagmap.categoryid', 'tag.id') - )) - ->andWhere($builder->expr()->eq('tag.type', $builder->createNamedParameter('files'))) - ->andWhere($builder->expr()->eq('tag.uid', $builder->createNamedParameter($user->getUID()))); - } - - $searchExpr = $this->querySearchHelper->searchOperatorToDBExpr($builder, $searchQuery->getSearchOperation()); - if ($searchExpr) { - $query->andWhere($searchExpr); - } - - if ($searchQuery->limitToHome() && ($this instanceof HomeCache)) { - $query->andWhere($builder->expr()->like('path', $query->expr()->literal('files/%'))); - } - - $this->querySearchHelper->addSearchOrdersToQuery($query, $searchQuery->getOrder()); - - if ($searchQuery->getLimit()) { - $query->setMaxResults($searchQuery->getLimit()); - } - if ($searchQuery->getOffset()) { - $query->setFirstResult($searchQuery->getOffset()); - } - - $result = $query->execute(); - $cacheEntries = $this->searchResultToCacheEntries($result); - $result->closeCursor(); - return $cacheEntries; + return $this->querySearchHelper->searchInCaches($searchQuery, [$this]); } /** @@ -949,7 +871,7 @@ class Cache implements ICache { $query->selectAlias($query->func()->sum('size'), 'f1') ->selectAlias($query->func()->min('size'), 'f2') ->from('filecache') - ->whereStorageId() + ->whereStorageId($this->getNumericStorageId()) ->whereParent($id); $result = $query->execute(); @@ -982,7 +904,7 @@ class Cache implements ICache { $query = $this->getQueryBuilder(); $query->select('fileid') ->from('filecache') - ->whereStorageId(); + ->whereStorageId($this->getNumericStorageId()); $result = $query->execute(); $files = $result->fetchAll(\PDO::FETCH_COLUMN); @@ -1006,7 +928,7 @@ class Cache implements ICache { $query = $this->getQueryBuilder(); $query->select('path') ->from('filecache') - ->whereStorageId() + ->whereStorageId($this->getNumericStorageId()) ->andWhere($query->expr()->lt('size', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT))) ->orderBy('fileid', 'DESC') ->setMaxResults(1); @@ -1028,7 +950,7 @@ class Cache implements ICache { $query = $this->getQueryBuilder(); $query->select('path') ->from('filecache') - ->whereStorageId() + ->whereStorageId($this->getNumericStorageId()) ->whereFileId($id); $result = $query->execute(); @@ -1127,4 +1049,16 @@ class Cache implements ICache { 'metadata_etag' => $entry->getMetadataEtag(), ]; } + + public function getQueryFilterForStorage(IQueryBuilder $builder) { + return $builder->expr()->eq('storage', $builder->createNamedParameter($this->getNumericStorageId(), IQueryBuilder::PARAM_INT)); + } + + public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry { + if ($rawEntry->getStorageId() === $this->getNumericStorageId()) { + return $rawEntry; + } else { + return null; + } + } } diff --git a/lib/private/Files/Cache/CacheEntry.php b/lib/private/Files/Cache/CacheEntry.php index bdefddab00a..156f075c2d0 100644 --- a/lib/private/Files/Cache/CacheEntry.php +++ b/lib/private/Files/Cache/CacheEntry.php @@ -124,4 +124,8 @@ class CacheEntry implements ICacheEntry { public function getData() { return $this->data; } + + public function __clone() { + $this->data = array_merge([], $this->data); + } } diff --git a/lib/private/Files/Cache/CacheQueryBuilder.php b/lib/private/Files/Cache/CacheQueryBuilder.php index 1fd5119f3ff..774691ebc31 100644 --- a/lib/private/Files/Cache/CacheQueryBuilder.php +++ b/lib/private/Files/Cache/CacheQueryBuilder.php @@ -35,13 +35,10 @@ use OCP\ILogger; * Query builder with commonly used helpers for filecache queries */ class CacheQueryBuilder extends QueryBuilder { - private $cache; private $alias = null; - public function __construct(IDBConnection $connection, SystemConfig $systemConfig, ILogger $logger, Cache $cache) { + public function __construct(IDBConnection $connection, SystemConfig $systemConfig, ILogger $logger) { parent::__construct($connection, $systemConfig, $logger); - - $this->cache = $cache; } public function selectFileCache(string $alias = null) { @@ -56,8 +53,8 @@ class CacheQueryBuilder extends QueryBuilder { return $this; } - public function whereStorageId() { - $this->andWhere($this->expr()->eq('storage', $this->createNamedParameter($this->cache->getNumericStorageId(), IQueryBuilder::PARAM_INT))); + public function whereStorageId(int $storageId) { + $this->andWhere($this->expr()->eq('storage', $this->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))); return $this; } diff --git a/lib/private/Files/Cache/FailedCache.php b/lib/private/Files/Cache/FailedCache.php index 01959585547..eddab8c19d3 100644 --- a/lib/private/Files/Cache/FailedCache.php +++ b/lib/private/Files/Cache/FailedCache.php @@ -22,6 +22,7 @@ namespace OC\Files\Cache; use OCP\Constants; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Cache\ICache; use OCP\Files\Cache\ICacheEntry; use OCP\Files\Search\ISearchQuery; @@ -138,4 +139,12 @@ class FailedCache implements ICache { public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int { throw new \Exception("Invalid cache"); } + + public function getQueryFilterForStorage(IQueryBuilder $builder) { + return 'false'; + } + + public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry { + return null; + } } diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php index fe0f1aae083..0b1bffa8e94 100644 --- a/lib/private/Files/Cache/QuerySearchHelper.php +++ b/lib/private/Files/Cache/QuerySearchHelper.php @@ -25,12 +25,17 @@ */ namespace OC\Files\Cache; +use OC\SystemConfig; use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\Files\Cache\ICache; use OCP\Files\IMimeTypeLoader; use OCP\Files\Search\ISearchBinaryOperator; use OCP\Files\Search\ISearchComparison; use OCP\Files\Search\ISearchOperator; use OCP\Files\Search\ISearchOrder; +use OCP\Files\Search\ISearchQuery; +use OCP\IDBConnection; +use OCP\ILogger; /** * Tools for transforming search queries into database queries @@ -58,14 +63,23 @@ class QuerySearchHelper { /** @var IMimeTypeLoader */ private $mimetypeLoader; + /** @var IDBConnection */ + private $connection; + /** @var SystemConfig */ + private $systemConfig; + /** @var ILogger */ + private $logger; - /** - * QuerySearchUtil constructor. - * - * @param IMimeTypeLoader $mimetypeLoader - */ - public function __construct(IMimeTypeLoader $mimetypeLoader) { + public function __construct( + IMimeTypeLoader $mimetypeLoader, + IDBConnection $connection, + SystemConfig $systemConfig, + ILogger $logger + ) { $this->mimetypeLoader = $mimetypeLoader; + $this->connection = $connection; + $this->systemConfig = $systemConfig; + $this->logger = $logger; } /** @@ -227,4 +241,97 @@ class QuerySearchHelper { $query->addOrderBy($order->getField(), $order->getDirection()); } } + + protected function getQueryBuilder() { + return new CacheQueryBuilder( + $this->connection, + $this->systemConfig, + $this->logger + ); + } + + /** + * @param ISearchQuery $searchQuery + * @param ICache[] $caches + * @return CacheEntry[] + */ + public function searchInCaches(ISearchQuery $searchQuery, array $caches): array { + // search in multiple caches at once by creating one query in the following format + // SELECT ... FROM oc_filecache WHERE + // <filter expressions from the search query> + // AND ( + // <filter expression for storage1> OR + // <filter expression for storage2> OR + // ... + // ); + // + // This gives us all the files matching the search query from all caches + // + // while the resulting rows don't have a way to tell what storage they came from (multiple storages/caches can share storage_id) + // we can just ask every cache if the row belongs to them and give them the cache to do any post processing on the result. + + $builder = $this->getQueryBuilder(); + + $query = $builder->selectFileCache('file'); + + $storageFilters = array_map(function (ICache $cache) use ($builder) { + return $cache->getQueryFilterForStorage($builder); + }, $caches); + + $query->andWhere($query->expr()->orX(...$storageFilters)); + + if ($this->shouldJoinTags($searchQuery->getSearchOperation())) { + $user = $searchQuery->getUser(); + if ($user === null) { + throw new \InvalidArgumentException("Searching by tag requires the user to be set in the query"); + } + $query + ->innerJoin('file', 'vcategory_to_object', 'tagmap', $builder->expr()->eq('file.fileid', 'tagmap.objid')) + ->innerJoin('tagmap', 'vcategory', 'tag', $builder->expr()->andX( + $builder->expr()->eq('tagmap.type', 'tag.type'), + $builder->expr()->eq('tagmap.categoryid', 'tag.id') + )) + ->andWhere($builder->expr()->eq('tag.type', $builder->createNamedParameter('files'))) + ->andWhere($builder->expr()->eq('tag.uid', $builder->createNamedParameter($user->getUID()))); + } + + $searchExpr = $this->searchOperatorToDBExpr($builder, $searchQuery->getSearchOperation()); + if ($searchExpr) { + $query->andWhere($searchExpr); + } + + if ($searchQuery->limitToHome() && ($this instanceof HomeCache)) { + $query->andWhere($builder->expr()->like('path', $query->expr()->literal('files/%'))); + } + + $this->addSearchOrdersToQuery($query, $searchQuery->getOrder()); + + if ($searchQuery->getLimit()) { + $query->setMaxResults($searchQuery->getLimit()); + } + if ($searchQuery->getOffset()) { + $query->setFirstResult($searchQuery->getOffset()); + } + + $result = $query->execute(); + $files = $result->fetchAll(); + + $rawEntries = array_map(function (array $data) { + return Cache::cacheEntryFromData($data, $this->mimetypeLoader); + }, $files); + + $result->closeCursor(); + + // loop trough all caches for each result to see if the result matches that storage + $results = []; + foreach ($rawEntries as $rawEntry) { + foreach ($caches as $cache) { + $entry = $cache->getCacheEntryFromSearchResult($rawEntry); + if ($entry) { + $results[] = $entry; + } + } + } + return $results; + } } diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php index 9b88591e1d1..9b85370a111 100644 --- a/lib/private/Files/Cache/Wrapper/CacheJail.php +++ b/lib/private/Files/Cache/Wrapper/CacheJail.php @@ -28,14 +28,8 @@ namespace OC\Files\Cache\Wrapper; use OC\Files\Cache\Cache; -use OC\Files\Search\SearchBinaryOperator; -use OC\Files\Search\SearchComparison; -use OC\Files\Search\SearchQuery; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Cache\ICacheEntry; -use OCP\Files\Search\ISearchBinaryOperator; -use OCP\Files\Search\ISearchComparison; -use OCP\Files\Search\ISearchQuery; /** * Jail to a subdirectory of the wrapped cache @@ -107,10 +101,6 @@ class CacheJail extends CacheWrapper { } } - /** - * @param ICacheEntry|array $entry - * @return array - */ protected function formatCacheEntry($entry) { if (isset($entry['path'])) { $entry['path'] = $this->getJailedPath($entry['path']); @@ -229,99 +219,6 @@ class CacheJail extends CacheWrapper { return $this->getCache()->getStatus($this->getSourcePath($file)); } - private function formatSearchResults($results) { - return array_map(function ($entry) { - $entry['path'] = $this->getJailedPath($entry['path'], $this->getGetUnjailedRoot()); - return $entry; - }, $results); - } - - /** - * search for files matching $pattern - * - * @param string $pattern - * @return array an array of file data - */ - public function search($pattern) { - // normalize pattern - $pattern = $this->normalize($pattern); - - if ($pattern === '%%') { - return []; - } - - $query = $this->getQueryBuilder(); - $query->selectFileCache() - ->whereStorageId() - ->andWhere($query->expr()->orX( - $query->expr()->like('path', $query->createNamedParameter($this->getGetUnjailedRoot() . '/%')), - $query->expr()->eq('path_hash', $query->createNamedParameter(md5($this->getGetUnjailedRoot()))), - )) - ->andWhere($query->expr()->iLike('name', $query->createNamedParameter($pattern))); - - $result = $query->execute(); - $files = $result->fetchAll(); - $result->closeCursor(); - - $results = array_map(function (array $data) { - return self::cacheEntryFromData($data, $this->mimetypeLoader); - }, $files); - return $this->formatSearchResults($results); - } - - /** - * search for files by mimetype - * - * @param string $mimetype - * @return array - */ - public function searchByMime($mimetype) { - $mimeId = $this->mimetypeLoader->getId($mimetype); - - $query = $this->getQueryBuilder(); - $query->selectFileCache() - ->whereStorageId() - ->andWhere($query->expr()->orX( - $query->expr()->like('path', $query->createNamedParameter($this->getGetUnjailedRoot() . '/%')), - $query->expr()->eq('path_hash', $query->createNamedParameter(md5($this->getGetUnjailedRoot()))), - )); - - if (strpos($mimetype, '/')) { - $query->andWhere($query->expr()->eq('mimetype', $query->createNamedParameter($mimeId, IQueryBuilder::PARAM_INT))); - } else { - $query->andWhere($query->expr()->eq('mimepart', $query->createNamedParameter($mimeId, IQueryBuilder::PARAM_INT))); - } - - $result = $query->execute(); - $files = $result->fetchAll(); - $result->closeCursor(); - - $results = array_map(function (array $data) { - return self::cacheEntryFromData($data, $this->mimetypeLoader); - }, $files); - return $this->formatSearchResults($results); - } - - public function searchQuery(ISearchQuery $query) { - $prefixFilter = new SearchComparison( - ISearchComparison::COMPARE_LIKE, - 'path', - $this->getGetUnjailedRoot() . '/%' - ); - $rootFilter = new SearchComparison( - ISearchComparison::COMPARE_EQUAL, - 'path', - $this->getGetUnjailedRoot() - ); - $operation = new SearchBinaryOperator( - ISearchBinaryOperator::OPERATOR_AND, - [new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [$prefixFilter, $rootFilter]) , $query->getSearchOperation()] - ); - $simpleQuery = new SearchQuery($operation, $query->getLimit(), $query->getOffset(), $query->getOrder(), $query->getUser()); - $results = $this->getCache()->searchQuery($simpleQuery); - return $this->formatSearchResults($results); - } - /** * update the folder size and the size of all parent folders * @@ -403,4 +300,28 @@ class CacheJail extends CacheWrapper { } return $this->getCache()->moveFromCache($sourceCache, $sourcePath, $this->getSourcePath($targetPath)); } + + public function getQueryFilterForStorage(IQueryBuilder $builder) { + $escapedRoot = $builder->getConnection()->escapeLikeParameter($this->getGetUnjailedRoot()); + + return $builder->expr()->andX( + $this->getCache()->getQueryFilterForStorage($builder), + $builder->expr()->orX( + $builder->expr()->eq('path_hash', $builder->createNamedParameter(md5($this->getGetUnjailedRoot()))), + $builder->expr()->like('path', $builder->createNamedParameter($escapedRoot . '/%')), + ) + ); + } + + public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry { + $rawEntry = $this->getCache()->getCacheEntryFromSearchResult($rawEntry); + if ($rawEntry) { + $jailedPath = $this->getJailedPath($rawEntry->getPath()); + if ($jailedPath !== null) { + return $this->formatCacheEntry(clone $rawEntry); + } + } + + return null; + } } diff --git a/lib/private/Files/Cache/Wrapper/CacheWrapper.php b/lib/private/Files/Cache/Wrapper/CacheWrapper.php index 01fbdd3bf42..edda332af67 100644 --- a/lib/private/Files/Cache/Wrapper/CacheWrapper.php +++ b/lib/private/Files/Cache/Wrapper/CacheWrapper.php @@ -30,6 +30,8 @@ namespace OC\Files\Cache\Wrapper; use OC\Files\Cache\Cache; +use OC\Files\Cache\QuerySearchHelper; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Cache\ICache; use OCP\Files\Cache\ICacheEntry; use OCP\Files\Search\ISearchQuery; @@ -45,6 +47,14 @@ class CacheWrapper extends Cache { */ public function __construct($cache) { $this->cache = $cache; + $this->mimetypeLoader = \OC::$server->getMimeTypeLoader(); + $this->connection = \OC::$server->getDatabaseConnection(); + $this->querySearchHelper = new QuerySearchHelper( + $this->mimetypeLoader, + $this->connection, + \OC::$server->getSystemConfig(), + \OC::$server->getLogger() + ); } protected function getCache() { @@ -215,31 +225,8 @@ class CacheWrapper extends Cache { return $this->getCache()->getStatus($file); } - /** - * search for files matching $pattern - * - * @param string $pattern - * @return ICacheEntry[] an array of file data - */ - public function search($pattern) { - $results = $this->getCache()->search($pattern); - return array_map([$this, 'formatCacheEntry'], $results); - } - - /** - * search for files by mimetype - * - * @param string $mimetype - * @return ICacheEntry[] - */ - public function searchByMime($mimetype) { - $results = $this->getCache()->searchByMime($mimetype); - return array_map([$this, 'formatCacheEntry'], $results); - } - - public function searchQuery(ISearchQuery $query) { - $results = $this->getCache()->searchQuery($query); - return array_map([$this, 'formatCacheEntry'], $results); + public function searchQuery(ISearchQuery $searchQuery) { + return $this->querySearchHelper->searchInCaches($searchQuery, [$this]); } /** @@ -321,4 +308,17 @@ class CacheWrapper extends Cache { public static function getById($id) { return parent::getById($id); } + + public function getQueryFilterForStorage(IQueryBuilder $builder) { + return $this->getCache()->getQueryFilterForStorage($builder); + } + + public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry { + $rawEntry = $this->getCache()->getCacheEntryFromSearchResult($rawEntry); + if ($rawEntry) { + return $this->formatCacheEntry(clone $rawEntry); + } + + return null; + } } |