Skip to content
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

Removing an entity that is contained in a m2m association fails when flush() is called twice #10485

Closed
wants to merge 1 commit into from

Conversation

mpdude
Copy link
Contributor

@mpdude mpdude commented Jan 31, 2023

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 a DELETE operation 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.

@mpdude mpdude changed the title Add failing test for #10483 Removing an entity that is contained in a m2m association fails when flush() is called twice Jan 31, 2023
@mpdude
Copy link
Contributor Author

mpdude commented Jan 31, 2023

Can anyone advise what would be the expected state of the collection after the UoW removed the entity from it?

…`flush()` is called twice

Here is a failing test for doctrine#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 a `DELETE` operation but fails since the entity (from the snapshot) is no longer in the identity map.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants