summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/Connector
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2023-06-02 23:11:30 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2023-07-07 17:55:31 +0200
commit5c0a1a4b096a9feb9f215fcf87acad1456d168e0 (patch)
treead536975c2e802a31418e9a3228200ac57f0de49 /apps/dav/lib/Connector
parent8d252731927fa7cb129d099d0b2b80711756db61 (diff)
downloadnextcloud-server-5c0a1a4b096a9feb9f215fcf87acad1456d168e0.tar.gz
nextcloud-server-5c0a1a4b096a9feb9f215fcf87acad1456d168e0.zip
fix: search with more than one search tags
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/dav/lib/Connector')
-rw-r--r--apps/dav/lib/Connector/Sabre/FilesReportPlugin.php26
1 files changed, 20 insertions, 6 deletions
diff --git a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
index 2cae9d948b5..c0cd382d994 100644
--- a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
@@ -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;
@@ -46,7 +45,6 @@ use Sabre\DAV\Xml\Element\Response;
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';
@@ -335,12 +333,28 @@ class FilesReportPlugin extends ServerPlugin {
// 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;