summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2023-07-06 18:09:12 +0200
committerGitHub <noreply@github.com>2023-07-06 18:09:12 +0200
commit1bdbb39eccedad577a0fb7d46777d0f2990e02da (patch)
treecde0f0fba02a20d67587c23abd77b4cc14ffe728
parent0e0b468c10b8a65cbf346c052cadbc8d834eb28f (diff)
parent789832698f1d24dac8af9b6b2f72a9156a2cf2aa (diff)
downloadnextcloud-server-1bdbb39eccedad577a0fb7d46777d0f2990e02da.tar.gz
nextcloud-server-1bdbb39eccedad577a0fb7d46777d0f2990e02da.zip
Merge pull request #39193 from nextcloud/fix/stable27/tag-search-short-circuit-master
[stable27] fix(TagSearchProvider): Short circuit if no tag matches the query
-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..5c731e42cc3 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(true, $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(