[6.x] Add support for filtering conditions in Assets Tag#13936
Open
jackmcdade wants to merge 1 commit into6.xfrom
Open
[6.x] Add support for filtering conditions in Assets Tag#13936jackmcdade wants to merge 1 commit into6.xfrom
jackmcdade wants to merge 1 commit into6.xfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| ? $this->assetsFromCollection($collection) | ||
| : $this->assetsFromContainer($id, $path); | ||
| if ($collection) { | ||
| return $this->outputCollection($this->assetsFromCollection($collection)); |
There was a problem hiding this comment.
Double filterByType applied on collection path
Low Severity
When the index() method takes the collection path, filterByType is applied twice. assetsFromCollection already calls filterByType on each field's value internally. Then outputCollection calls applyPostCollectionFilters, which calls filterByType again on the entire resulting collection. While functionally idempotent for now, this is redundant and risks inconsistency if filterByType behavior ever changes.
Additional Locations (1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


References statamic/ideas#1003
Note
Medium Risk
Changes the assets tag’s core retrieval path from in-memory collection filtering to database/query-builder constraints, which may affect result ordering/edge cases and pagination behavior; covered by new tests but touches widely used template tag behavior.
Overview
The
assetstag now queries containers via an asset query builder (instead of fetching then filtering), enablingfield:conditionfiltering,query_scope, and query-level sorting/pagination/chunking via the shared tag concerns.Legacy params (
folder/recursive,type,not_in,sort,limit/offset) are preserved by applying them as query constraints where possible and as post-processing filters for collections/paginators/chunks. Adds a focusedAssetsTestsuite covering condition filtering (including localized fields), scopes, pagination output shape, and legacy behavior.Written by Cursor Bugbot for commit 6d4a4fb. This will update automatically on new commits. Configure here.