Fix to-many collections left in dirty state after entities are removed by the UoW#10486
Merged
Merged
Conversation
jacquesbh
added a commit
to jacquesbh/doctrine-orm
that referenced
this pull request
Apr 4, 2023
…d by the UoW @see doctrine#10486 Co-authored: Matthias Pigulla <[email protected]>
jacquesbh
added a commit
to jacquesbh/doctrine-orm
that referenced
this pull request
Apr 4, 2023
…d by the UoW @see doctrine#10486 Co-authored-by: Matthias Pigulla <[email protected]>
|
Hi Guys, this would be the solution we currently have in a project. Is there any chance one could review this asap? |
greg0ire
reviewed
Apr 13, 2023
Contributor
Author
|
@SenseException maybe you could review this? |
SenseException
previously approved these changes
May 10, 2023
eb7e540 to
a951369
Compare
greg0ire
approved these changes
May 11, 2023
Member
|
Thanks @mpdude ! |
Contributor
Author
|
Thank you for fixing the remaining issues |
Contributor
Author
|
@greg0ire could you close the fixed issues I referenced in the initial post? Thanks. |
Member
|
🤔 that's been done automatically, hasn't it? Everything in the first message is either merged or closed. |
Contributor
Author
|
Sorry, you’re right. I had the impression that did not work in other cases when a PR opened by me claims to close issues raised by others. |
Member
|
Yes, it has happened to me as well. |
This was referenced Jun 3, 2023
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.
Current situation
When an entity is removed from the EM, the UoW updates collections that contain that entity, removing it from the collections as well.
The collections are left in a dirty state afterwards with outdated snapshots, which leads to errors e. g. when the Entity Manager is flushed again (see #10485).
Suggested fix
This PR fixes the problem by moving a check further down, so that also collections updated by the UoW itself (by removing the entity in question) are captured as "processed" by the current commit phase.
Tests added
It seems tests for this feature were completely missing, so I added them.
Also added a second test case for the feature added in #256 that the event for many-to-many collections is not only generated for added, but also for removed entities.
Closes #10485, fixes #10483, fixes #10060, closes #10061.