summaryrefslogtreecommitdiffstats
path: root/lib/private
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-16 12:47:15 +0200
commit298af3cf0acc0546668314d09717cca409100106 (patch)
tree2860ae5eb754ca38081d4ba528c1cd0fefcb692a /lib/private
parentf2b5a079db5530cf48be137e5a52a984e27ab3ad (diff)
downloadnextcloud-server-298af3cf0acc0546668314d09717cca409100106.tar.gz
nextcloud-server-298af3cf0acc0546668314d09717cca409100106.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/private')
-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(),