mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #10485] Removing an entity that is contained in a m2m association fails when flush() is called twice
#12394
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/10485
State: closed
Merged: No
Here is a failing test for #10483.
When an entity is removed that is part of a many-to-many collection, that collection will be updated during the
flush()operation to no longer contain the entity.However, afterwards the collection will be in a dirty state and the internal snapshot still contains the removed entity.
That causes the collection to be processed again when
flush()is called another time. This time, the ORM assumes the entity has been removed from the collection. It will try to build aDELETEoperation but fails since the entity (from the snapshot) is no longer in the identity map.The error message is
Doctrine\ORM\EntityNotFoundException: Unable to find "..." entity identifier associated with the UnitOfWork.