[PR #10486] Fix to-many collections left in dirty state after entities are removed by the UoW #12397

Closed
opened 2026-01-22 16:13:55 +01:00 by admin · 0 comments
Owner

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.

**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.
admin added the pull-request label 2026-01-22 16:13:55 +01:00
admin closed this issue 2026-01-22 16:13:56 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#12397