mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #10486] Fix to-many collections left in dirty state after entities are removed by the UoW #12397
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/10486
State: closed
Merged: Yes
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.