aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2023-06-29 15:01:14 +0200
committerMarcel Klehr <mklehr@gmx.net>2023-06-30 12:32:25 +0200
commit2951ae277d1484986581458aa88f5663a695f3cc (patch)
tree7326be1bb0913a467f1aab269dfcb9b3585cccb0 /apps
parent7b7148c206c2a15d497124c6e7dbac082e6a7a20 (diff)
downloadnextcloud-server-2951ae277d1484986581458aa88f5663a695f3cc.tar.gz
nextcloud-server-2951ae277d1484986581458aa88f5663a695f3cc.zip
fix(TagSearchProvider): Short circuit if no tag matches the query
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'apps')
-rw-r--r--apps/systemtags/lib/Search/TagSearchProvider.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/apps/systemtags/lib/Search/TagSearchProvider.php b/apps/systemtags/lib/Search/TagSearchProvider.php
index 7a7cb0b061c..d775629b674 100644
--- a/apps/systemtags/lib/Search/TagSearchProvider.php
+++ b/apps/systemtags/lib/Search/TagSearchProvider.php
@@ -113,6 +113,11 @@ class TagSearchProvider implements IProvider {
* @inheritDoc
*/
public function search(IUser $user, ISearchQuery $query): SearchResult {
+ $matchingTags = $this->tagManager->getAllTags(1, $query->getTerm());
+ if (count($matchingTags) === 0) {
+ return SearchResult::complete($this->l10n->t('Tags'), []);
+ }
+
$userFolder = $this->rootFolder->getUserFolder($user->getUID());
$fileQuery = new SearchQuery(
new SearchBinaryOperator(SearchBinaryOperator::OPERATOR_OR, [
@@ -133,7 +138,6 @@ class TagSearchProvider implements IProvider {
return $node->getId();
}, $searchResults);
$matchedTags = $this->objectMapper->getTagIdsForObjects($resultIds, 'files');
- $relevantTags = $this->tagManager->getTagsByIds(array_unique($this->flattenArray($matchedTags)));
// prepare direct tag results
$tagResults = array_map(function(ISystemTag $tag) {
@@ -149,9 +153,7 @@ class TagSearchProvider implements IProvider {
'icon-tag'
);
return $searchResultEntry;
- }, array_filter($relevantTags, function($tag) use ($query) {
- return $tag->isUserVisible() && strpos($tag->getName(), $query->getTerm()) !== false;
- }));
+ }, $matchingTags);
// prepare files results
return SearchResult::paginated(