-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Bug description
In the Unified Search, when searching for tags, some tags are not displayed in the "All tagged X ..." results even though files with those tags are found.
Steps to reproduce
-
Create several tags with names containing the same word, e.g.:
- "Beautiful girl" - this one has a low ID like 2
- "Girl in dress" - higher ID like 23
- "Girl in shorts" - higher ID like 21
-
Assign these tags to some files
-
Use Unified Search to search for "girl"
-
Observe that:
- Files with all tags are found correctly
- "All tagged Girl in dress ..." appears
- "All tagged Girl in shorts ..." appears
- "All tagged Beautiful girl ..." is MISSING (the tag with low ID)
Expected behavior
All matching tags should appear in the "All tagged X ..." results list.
Actual behavior
Tags with low IDs (like 2, 3, etc.) that match file result array indices are silently dropped.
Root cause
In apps/systemtags/lib/Search/TagSearchProvider.php, line 137-138:
}, $searchResults)
+ $tagResults, The + operator in PHP preserves keys from the first array. The $tagResults array has tag IDs as keys (e.g., [2 => ..., 21 => ..., 23 => ...]), while array_map() on $searchResults creates sequential indices [0, 1, 2, 3, ...].
When arrays are merged with +, if a key exists in the first array, the value from the second array is ignored. So tag with ID=2 collides with file result at index 2 and gets dropped.
Proposed fix
Replace:
array_map(..., $searchResults) + $tagResults,
With:
array_merge(array_values(array_map(..., $searchResults)), array_values($tagResults)),
This ensures all elements are included regardless of their original keys.
Environment
- Nextcloud version: 31.0.9
- PHP version: 8.x