check if other instances have value before joining relations table#16919
Merged
brandonkelly merged 5 commits into5.xfrom Mar 19, 2025
Merged
Conversation
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.
Description
This can be reproduced with a single site setup and with adding a value to the relation field via the control panel:
relationswith an entry type that can have just the default titlerelationssectionblogsection with an entry type that contains that entries field added twiceblogsection, fill out the title and fully saveFor compatibility reasons with versions < 5.3.0, if the first instance of a relation field is
null, we join in the legacyrelationstable and populate that first instance (as in the first one added to the layout, not the first one on the page) with its content.This problem was exacerbated by #16818 because, when duplicating the element (e.g. to create a provisional draft), we no longer add an empty array as the value of the relation field.
Fix: if the value of the first instance of the field is
null, check if we have more than one instance of it in the layout, and if so, if any of those instances have a value. If yes, then don’t join in the relations table.(While working on this, I discovered a potential bug related to the resave job the happens with and without this change. To be discussed internally.)
Related issues
#16912