diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2023-05-11 13:08:57 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2023-06-21 18:19:08 +0200 |
commit | 783e32a64da72d1fe15b983f14297daaaad0dff8 (patch) | |
tree | 18f6fd3536ad5f80904a90f53ef2717098b16433 /lib/private/Files/Cache | |
parent | b0d1cf57301a06aef08f9cae0ee96b0f29fb10a9 (diff) | |
download | nextcloud-server-783e32a64da72d1fe15b983f14297daaaad0dff8.tar.gz nextcloud-server-783e32a64da72d1fe15b983f14297daaaad0dff8.zip |
fix: favorites view and universal search against tags
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private/Files/Cache')
-rw-r--r-- | lib/private/Files/Cache/QuerySearchHelper.php | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php index e2a9572c5f7..0f9c6eeaa88 100644 --- a/lib/private/Files/Cache/QuerySearchHelper.php +++ b/lib/private/Files/Cache/QuerySearchHelper.php @@ -40,6 +40,7 @@ use OCP\Files\Search\ISearchBinaryOperator; use OCP\Files\Search\ISearchComparison; use OCP\Files\Search\ISearchQuery; use OCP\IDBConnection; +use OCP\IUser; use Psr\Log\LoggerInterface; class QuerySearchHelper { @@ -118,6 +119,29 @@ class QuerySearchHelper { return $tags; } + protected function equipQueryForSystemTags(CacheQueryBuilder $query): void { + $query + ->leftJoin('file', 'systemtag_object_mapping', 'systemtagmap', $query->expr()->andX( + $query->expr()->eq('file.fileid', $query->expr()->castColumn('systemtagmap.objectid', IQueryBuilder::PARAM_INT)), + $query->expr()->eq('systemtagmap.objecttype', $query->createNamedParameter('files')) + )) + ->leftJoin('systemtagmap', 'systemtag', 'systemtag', $query->expr()->andX( + $query->expr()->eq('systemtag.id', 'systemtagmap.systemtagid'), + $query->expr()->eq('systemtag.visibility', $query->createNamedParameter(true)) + )); + } + + protected function equipQueryForDavTags(CacheQueryBuilder $query, IUser $user): void { + $query + ->leftJoin('file', 'vcategory_to_object', 'tagmap', $query->expr()->eq('file.fileid', 'tagmap.objid')) + ->leftJoin('tagmap', 'vcategory', 'tag', $query->expr()->andX( + $query->expr()->eq('tagmap.type', 'tag.type'), + $query->expr()->eq('tagmap.categoryid', 'tag.id'), + $query->expr()->eq('tag.type', $query->createNamedParameter('files')), + $query->expr()->eq('tag.uid', $query->createNamedParameter($user->getUID())) + )); + } + /** * Perform a file system search in multiple caches * @@ -156,27 +180,16 @@ class QuerySearchHelper { if ($searchQuery->getSearchOperation() instanceof ISearchComparison) { switch ($searchQuery->getSearchOperation()->getField()) { case 'systemtag': - $query - ->leftJoin('file', 'systemtag_object_mapping', 'systemtagmap', $builder->expr()->andX( - $builder->expr()->eq('file.fileid', $builder->expr()->castColumn('systemtagmap.objectid', IQueryBuilder::PARAM_INT)), - $builder->expr()->eq('systemtagmap.objecttype', $builder->createNamedParameter('files')) - )) - ->leftJoin('systemtagmap', 'systemtag', 'systemtag', $builder->expr()->andX( - $builder->expr()->eq('systemtag.id', 'systemtagmap.systemtagid'), - $builder->expr()->eq('systemtag.visibility', $builder->createNamedParameter(true)) - )); + $this->equipQueryForSystemTags($query); break; case 'tagname': - $query - ->leftJoin('file', 'vcategory_to_object', 'tagmap', $builder->expr()->eq('file.fileid', 'tagmap.objid')) - ->leftJoin('tagmap', 'vcategory', 'tag', $builder->expr()->andX( - $builder->expr()->eq('tagmap.type', 'tag.type'), - $builder->expr()->eq('tagmap.categoryid', 'tag.id'), - $builder->expr()->eq('tag.type', $builder->createNamedParameter('files')), - $builder->expr()->eq('tag.uid', $builder->createNamedParameter($user->getUID())) - )); + case 'favorite': + $this->equipQueryForDavTags($query, $user); break; } + } elseif ($searchQuery->getSearchOperation() instanceof SearchBinaryOperator) { + $this->equipQueryForSystemTags($query); + $this->equipQueryForDavTags($query, $user); } } |