clear out ownerId and primaryOwnerId so the lazy eager loading works for all blocks #17470
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.
Description
In some cases, the lazy eager loading for the matrix field in inline-editable blocks mode was only finding elements owned by the first nested entry (block).
When getting blocks for the matrix field in the inline-editable blocks mode, we use lazy eager loading: https://github.com/craftcms/cms/blob/5.7.10/src/fields/Matrix.php#L934
When the time came to find the target elements, the query had the
ownerId
parameter set to the ID of the first entry (block) we were eager loading for, which caused the results to be incorrectly limited by thatownerId
.Steps to reproduce:
matrix - blocks 3
Matrix field (inline-editable blocks view mode) with an entry type that can have only the titlematrix - blocks 2
Matrix field (inline-editable blocks view mode) with an entry type that contains thematrix - blocks 3
field; make thematrix - blocks 3
field required;matrix - blocks 1
Matrix field (inline-editable blocks view mode) with an entry type that containsmatrix - blocks 2
fieldmatrix - blocks 1
fieldmatrix - blocks 1
block, title: ”c1“;matrix - blocks 2
blocks, one with title ”c1.1“, the other with title ”c1.2“;matrix - blocks 3
block with title ”c1.1.1“;matrix - blocks 3
block with title ”c1.2.1“;matrix - blocks 2
block and try to savematrix - blocks 3
are required)matrix - blocks 3
is missing; if you reload the page, it'll appear againRelated issues
n/a - reported by @tommysvr