Skip to content

[12.x] Ensure automatic eager loading works in events #56193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: 12.x
Choose a base branch
from

Conversation

jackbayliss
Copy link
Contributor

@jackbayliss jackbayliss commented Jul 1, 2025

Still WIP as seems to clash with lazy loading violations

When automatic eager loading is enabled, it seems to break when used in observers or within model booted methods.
It sets the relation to null, even if there is a relation - meaning tests etc that used to pass, no longer pass.

I've added a test to prove it now works, if you remove the changes I've added in the Collection class it will then fail.

Adding what I have into loadMissingRelationshipChain seems safe enough imo, as it's only used when eager loading is enabled, and no other eager loading tests have been affected.

Open to suggestions, but thought I'd give it a crack.

Copy link

github-actions bot commented Jul 1, 2025

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant