summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2023-05-11 11:22:27 +0200
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2023-07-07 14:54:55 +0000
commitc33f72824962203517097ab906bb334ded0022d9 (patch)
tree55276cd9fa4c472c4acc466282104703db058300
parentb172df69d68158bf71b79a8acdbb6629e27d2ee2 (diff)
downloadnextcloud-server-c33f72824962203517097ab906bb334ded0022d9.tar.gz
nextcloud-server-c33f72824962203517097ab906bb334ded0022d9.zip
fix: change if with conditionless else to switch; and a parameter value
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
-rw-r--r--lib/private/Files/Cache/QuerySearchHelper.php43
-rw-r--r--lib/private/Files/Node/Folder.php2
2 files changed, 25 insertions, 20 deletions
diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php
index b119bcd24a6..a7b51685160 100644
--- a/lib/private/Files/Cache/QuerySearchHelper.php
+++ b/lib/private/Files/Cache/QuerySearchHelper.php
@@ -152,25 +152,30 @@ class QuerySearchHelper {
if ($user === null) {
throw new \InvalidArgumentException("Searching by tag requires the user to be set in the query");
}
- if ($searchQuery->getSearchOperation() instanceof ISearchComparison && $searchQuery->getSearchOperation()->getField() === '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))
- ));
- } else {
- $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()))
- ));
+ 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))
+ ));
+ 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()))
+ ));
+ break;
+ }
}
}
diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php
index 004c1bba87d..d42c7e9a628 100644
--- a/lib/private/Files/Node/Folder.php
+++ b/lib/private/Files/Node/Folder.php
@@ -297,7 +297,7 @@ class Folder extends Node implements \OCP\Files\Folder {
* @return Node[]
*/
public function searchByTag($tag, $userId) {
- $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'tag', $tag), $userId);
+ $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'tagname', $tag), $userId);
return $this->search($query);
}