Skip to content

Commit db1306b

Browse files
blizzzbackportbot-nextcloud[bot]
authored andcommitted
fix: cannot apply limit+offset on multi-tag-search
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent dfbedda commit db1306b

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

apps/dav/lib/Connector/Sabre/FilesReportPlugin.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,15 @@ protected function processFilterRulesForFileNodes(array $filterRules, ?int $limi
338338
// exposed in API yet
339339
if (!empty($systemTagIds)) {
340340
$tags = $this->tagManager->getTagsByIds($systemTagIds, $this->userSession->getUser());
341+
342+
// For we run DB queries per tag and require intersection, we cannot apply limit and offset for DB queries on multi tag search.
343+
$oneTagSearch = count($tags) === 1;
344+
$dbLimit = $oneTagSearch ? $limit ?? 0 : 0;
345+
$dbOffset = $oneTagSearch ? $offset ?? 0 : 0;
346+
341347
foreach ($tags as $tag) {
342348
$tagName = $tag->getName();
343-
$tmpNodes = $this->userFolder->searchBySystemTag($tagName, $this->userSession->getUser()->getUID(), $limit ?? 0, $offset ?? 0);
349+
$tmpNodes = $this->userFolder->searchBySystemTag($tagName, $this->userSession->getUser()->getUID(), $dbLimit, $dbOffset);
344350
if (count($nodes) === 0) {
345351
$nodes = $tmpNodes;
346352
} else {
@@ -353,6 +359,10 @@ protected function processFilterRulesForFileNodes(array $filterRules, ?int $limi
353359
return $nodes;
354360
}
355361
}
362+
363+
if (!$oneTagSearch && ($limit !== null || $offset !== null)) {
364+
$nodes = array_slice($nodes, $offset, $limit);
365+
}
356366
}
357367

358368
return $nodes;

0 commit comments

Comments
 (0)