-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Skip joined entity creation for empty relation (#10889) #11194
Conversation
467f5c4
to
95aa431
Compare
What does it mean when the |
ah you're right it's an oversight. During my tests I wanted to see how the ObjectHydrator behaved with a simple ID rather than a relationship, and I left an annotation. It doesn't change anything about the problem here but I'm going to remove it ASAP |
95aa431
to
429e274
Compare
@mpdude It's corrected. I checked, I still have the same problem without the |
I don't think the failed psalm static analysis is related to my changes |
@mpdude |
We've tested the changes from this PR in Sulu, everything seems to be running without encountering any issues. However, until this is merged, we also have to lock the doctrine version in our customer projects to v2.15. Given this situation, we would greatly appreciate it if you could prioritise merging this PR. |
The PR cannot be merged due to conflicts. |
@noemi-salaun will you be able to resolve these conflicts? |
@derrabus I just rebased my work on the 2.19.x branch, it should be good now |
d32c09b
to
75912dc
Compare
@greg0ire I changed the test with entities with less meaning |
75912dc
to
2645de3
Compare
2645de3
to
3b49913
Compare
Thanks @noemi-salaun ! |
(The following is translated from french with Google Translate, I'm sorry :/ )
In case the root entity has its primary key as a relationship and the joined entity has a simple primary key, the RSM orders the ID of the joined entity before having the ID which defined the root entity.
The ObjectHydrator therefore first tries to hydrate the joined entity. We then fall into a special case where the parent (the root entity) has not yet been created and the hydrator tries to start by creating the child, except that in our case, the child is supposed to be null.
I therefore added the
isset($nonemptyComponents[$dqlAlias])
check which we find further in the code and which is made to skip the creation of the joined entity when the parent is already hydrated. I think it makes sense to do the same check in the case where the hydrator starts with the joined entity.