[6.x] Fix edge case causing a BadMethodCallExceptions to be thrown when using loadMissing() #37871
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.
Sometimes when relations are loaded, a collection of
null
andBaseCollection
s is returned. When this happens, the->first() instanceof BaseCollection
check can be false, as the first value can be null, in which case->collapse()
is incorrectly skipped.There have been a few PRs more properly describing this issue, but these have been closed rather than merged:
#32043
#32053 (Comment by nal-chris on 18 Mar describes it pretty well)
I've chosen non-descriptive names for a few relations, feel free to suggest something more concrete (though these serve their purpose).
This is a replacement for #37864, which targeted 8.x.