Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: search with more than one search tags
Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed Jul 7, 2023
commit 5c0a1a4b096a9feb9f215fcf87acad1456d168e0
26 changes: 20 additions & 6 deletions apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/
namespace OCA\DAV\Connector\Sabre;

use OC\Files\Node\LazyFolder;
use OC\Files\View;
use OCP\App\IAppManager;
use OCP\Files\Folder;
Expand All @@ -46,7 +45,6 @@
use Sabre\DAV\Xml\Response\MultiStatus;

class FilesReportPlugin extends ServerPlugin {

// namespace
public const NS_OWNCLOUD = 'http://owncloud.org/ns';
public const NS_NEXTCLOUD = 'http://nextcloud.org/ns';
Expand Down Expand Up @@ -335,12 +333,28 @@ protected function processFilterRulesForFileNodes(array $filterRules, ?int $limi
// exposed in API yet
if (
!empty($systemTagIds)
&& ($this->userFolder instanceof \OC\Files\Node\Folder
|| $this->userFolder instanceof LazyFolder)
&& (method_exists($this->userFolder, 'searchBySystemTag'))
) {
$tags = $this->tagManager->getTagsByIds($systemTagIds);
$tagName = (current($tags))->getName();
$nodes = $this->userFolder->searchBySystemTag($tagName, $this->userSession->getUser()->getUID(), $limit ?? 0, $offset ?? 0);
foreach ($tags as $tag) {
if (!$tag->isUserVisible()) {
// searchBySystemTag() also has the criteria to include only user visible tags. They can be skipped early nevertheless.
continue;
}
$tagName = $tag->getName();
$tmpNodes = $this->userFolder->searchBySystemTag($tagName, $this->userSession->getUser()->getUID(), $limit ?? 0, $offset ?? 0);
if (count($nodes) === 0) {
$nodes = $tmpNodes;
} else {
$nodes = array_uintersect($nodes, $tmpNodes, function (\OCP\Files\Node $a, \OCP\Files\Node $b): int {
return $a->getId() - $b->getId();
});
}
if ($nodes === []) {
// there cannot be a common match when nodes are empty early.
return $nodes;
}
}
}

return $nodes;
Expand Down
Loading