summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2023-06-27 22:49:08 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2023-07-06 21:52:53 +0200
commit35de0b5504c43722e4a7c66e8830687130652b23 (patch)
tree7149ab59631f6143d1cb5ac06d6f6e529edbad1d /apps/dav
parentd05d1858625dfca5a10b8407c72501e42d11a04a (diff)
downloadnextcloud-server-35de0b5504c43722e4a7c66e8830687130652b23.tar.gz
nextcloud-server-35de0b5504c43722e4a7c66e8830687130652b23.zip
fix: cannot apply limit+offset on multi-tag-search
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/Connector/Sabre/FilesReportPlugin.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
index 6122ba1bfe7..4b26d837779 100644
--- a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
@@ -338,9 +338,15 @@ class FilesReportPlugin extends ServerPlugin {
// exposed in API yet
if (!empty($systemTagIds)) {
$tags = $this->tagManager->getTagsByIds($systemTagIds, $this->userSession->getUser());
+
+ // For we run DB queries per tag and require intersection, we cannot apply limit and offset for DB queries on multi tag search.
+ $oneTagSearch = count($tags) === 1;
+ $dbLimit = $oneTagSearch ? $limit ?? 0 : 0;
+ $dbOffset = $oneTagSearch ? $offset ?? 0 : 0;
+
foreach ($tags as $tag) {
$tagName = $tag->getName();
- $tmpNodes = $this->userFolder->searchBySystemTag($tagName, $this->userSession->getUser()->getUID(), $limit ?? 0, $offset ?? 0);
+ $tmpNodes = $this->userFolder->searchBySystemTag($tagName, $this->userSession->getUser()->getUID(), $dbLimit, $dbOffset);
if (count($nodes) === 0) {
$nodes = $tmpNodes;
} else {
@@ -353,6 +359,10 @@ class FilesReportPlugin extends ServerPlugin {
return $nodes;
}
}
+
+ if (!$oneTagSearch && ($limit !== null || $offset !== null)) {
+ $nodes = array_slice($nodes, $offset, $limit);
+ }
}
return $nodes;