aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2023-05-10 18:40:44 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2023-05-10 18:48:06 +0200
commitdf662f50bdfadbb72e48202dd52c689f8c122b9c (patch)
treef7623823ccab88a0ebace3942b8e0669ca4179bc /lib
parentdbfd2f936aaae95aabd52ac8de03b48a813bbb8f (diff)
downloadnextcloud-server-df662f50bdfadbb72e48202dd52c689f8c122b9c.tar.gz
nextcloud-server-df662f50bdfadbb72e48202dd52c689f8c122b9c.zip
refactor: remove where specification from SELECT getter
- search constraints are now fully in control of SystemTagsInFilesDetector::detectAssignedSystemTagsIn(), avoids duplication of a WHERE statement Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Cache/CacheQueryBuilder.php1
-rw-r--r--lib/private/Files/Cache/QuerySearchHelper.php2
-rw-r--r--lib/private/SystemTag/SystemTagsInFilesDetector.php12
3 files changed, 8 insertions, 7 deletions
diff --git a/lib/private/Files/Cache/CacheQueryBuilder.php b/lib/private/Files/Cache/CacheQueryBuilder.php
index c5563750c4d..34d2177b84e 100644
--- a/lib/private/Files/Cache/CacheQueryBuilder.php
+++ b/lib/private/Files/Cache/CacheQueryBuilder.php
@@ -55,7 +55,6 @@ class CacheQueryBuilder extends QueryBuilder {
$this->expr()->eq('systemtag.id', 'systemtagmap.systemtagid'),
$this->expr()->eq('systemtag.visibility', $this->createNamedParameter(true))
))
- ->where($this->expr()->like('systemtag.name', $this->createNamedParameter('_%')))
->groupBy('systemtag.name', 'systemtag.id', 'systemtag.visibility', 'systemtag.editable');
return $this;
diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php
index f540f2dcb65..30b3c7225ac 100644
--- a/lib/private/Files/Cache/QuerySearchHelper.php
+++ b/lib/private/Files/Cache/QuerySearchHelper.php
@@ -35,7 +35,6 @@ use OCP\Files\Cache\ICache;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Folder;
use OCP\Files\IMimeTypeLoader;
-use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Search\ISearchBinaryOperator;
use OCP\Files\Search\ISearchQuery;
@@ -228,5 +227,4 @@ class QuerySearchHelper {
return [$caches, $mountByMountPoint];
}
-
}
diff --git a/lib/private/SystemTag/SystemTagsInFilesDetector.php b/lib/private/SystemTag/SystemTagsInFilesDetector.php
index 0fcd7e051f6..c9f26c58c02 100644
--- a/lib/private/SystemTag/SystemTagsInFilesDetector.php
+++ b/lib/private/SystemTag/SystemTagsInFilesDetector.php
@@ -28,9 +28,11 @@ namespace OC\SystemTag;
use OC\Files\Cache\QuerySearchHelper;
use OC\Files\Node\Root;
+use OC\Files\Search\SearchBinaryOperator;
use OC\Files\Search\SearchComparison;
use OC\Files\Search\SearchQuery;
use OCP\Files\Folder;
+use OCP\Files\Search\ISearchBinaryOperator;
use OCP\Files\Search\ISearchComparison;
class SystemTagsInFilesDetector {
@@ -43,13 +45,15 @@ class SystemTagsInFilesDetector {
int $limit = 0,
int $offset = 0
): array {
+ $operator = new SearchComparison(ISearchComparison::COMPARE_LIKE, 'systemtag', '%');
// Currently query has to have exactly one search condition. If no media type is provided,
// we fall back to the presence of a system tag.
- if (empty($filteredMediaType)) {
- $query = new SearchQuery(new SearchComparison(ISearchComparison::COMPARE_LIKE, 'systemtag', '%'), $limit, $offset, []);
- } else {
- $query = new SearchQuery(new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $filteredMediaType . '/%'), $limit, $offset, []);
+ if ($filteredMediaType !== '') {
+ $mimeOperator = new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $filteredMediaType . '/%');
+ $operator = new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [$operator, $mimeOperator]);
}
+
+ $query = new SearchQuery($operator, $limit, $offset, []);
[$caches, ] = $this->searchHelper->getCachesAndMountPointsForSearch(
$this->getRootFolder($folder),
$folder->getPath(),