Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media collections are lazy loaded with preventLazyLoading() enabled #3554

Open
sebastiaanluca opened this issue Feb 27, 2024 · 2 comments
Open

Comments

@sebastiaanluca
Copy link

This concerns #2784

I noticed in our old admin panel that we had a lot of lazy loaded media relations. We didn't get a warning about it (for 2 years 馃槃), even with Model::preventLazyLoading(); enabled globally. The cause for this is that doing loadMissing() on each object in a loop doesn't trigger the exception even though it's technically an n+1 issue.

The solution to this is to always eager load relations manually in the controller, not in models or traits. Removing this would be a breaking change, but are you open to it? I expect a lot of package users have tons of n+1 media issues but aren't aware, unless you manually inspect the debug bar queries for each page you use media in collections.

@freekmurze
Copy link
Member

I would be open for a PR 馃憤

@sebastiaanluca
Copy link
Author

We'll try to look into it next sprint. Maybe we can also make this configurable so it's not a breaking change.

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

No branches or pull requests

3 participants