diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2023-05-11 11:22:27 +0200 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2023-07-06 17:29:12 +0000 |
commit | 7d8d586983bd3b889fdba63ef2d364a0db7fc749 (patch) | |
tree | 55870de185ed8f570f1fbdd800fc8f83bcd00ab9 /lib/private/Files/Cache/QuerySearchHelper.php | |
parent | 7bfe6f2cc075be8fe7b871ebcff40934b5063dc6 (diff) | |
download | nextcloud-server-7d8d586983bd3b889fdba63ef2d364a0db7fc749.tar.gz nextcloud-server-7d8d586983bd3b889fdba63ef2d364a0db7fc749.zip |
fix: change if with conditionless else to switch; and a parameter value
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private/Files/Cache/QuerySearchHelper.php')
-rw-r--r-- | lib/private/Files/Cache/QuerySearchHelper.php | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php index ea763a76846..572c49d8ee7 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; + } } } |