mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Unable to find "App\Entity\Role" entity identifier associated with the UnitOfWork #7103
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?
Originally created by @specdrum-agc on GitHub (Jan 30, 2023).
Bug Report
Unable to find "App\Entity\Role" entity identifier associated with the UnitOfWork
Summary
When I try to flush changes in one Entity, that related to deleted one, exception is thrown.
Current behavior
Somewhat works wrong when deleting ManyToMany relation and saving related entity after flushing these changes.
I investigated the problem and found out that removing entity inside of method
computeAssociationChangesdoes not detect such changes and collection stays dirty.How to reproduce
https://github.com/specdrum-agc/doctrine-bug (See Readme)
The main part of test case
The test case might be strange, but I have similar behavior in real application. I have second flush in different part of application than first.
Expected behavior
Second
flushcall do not throw exception.@mpdude commented on GitHub (Jan 30, 2023):
So you change the user that it has to be flushed, but the
rolesassociation still contains the role that has been deleted?@specdrum-agc commented on GitHub (Jan 31, 2023):
No, it doesn't. Only in collection's snapshot.
This is the point that state of collection comes into invalid state. When second flush in progress, UnitOfWork sees that and try to persist that change, but it was persisted in first flush.
@mpdude commented on GitHub (Jan 31, 2023):
Did this work in previous ORM versions?
@specdrum-agc commented on GitHub (Jan 31, 2023):
I had 2.11.3 version installed, there was the same issue.
@mpdude commented on GitHub (Jan 31, 2023):
I am not sure what the expected behaviour would be, but #10485 provides a failing test for the time being.
@specdrum-agc commented on GitHub (Jan 31, 2023):
@mpdude Thank you very much for adding test case for this issue! It reproduces the mentioned behavior. But looks like you are left excess comma on line 20. Test log says about it.
@mpdude commented on GitHub (Jan 31, 2023):
#10486 might be a fix
@mpdude commented on GitHub (Feb 15, 2023):
Duplicate: #10060