mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
(Temp Fix available) Conflict with spl_object_hash on merge of to-many association when not mirrored on owning side #5337
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 @Goatfried on GitHub (Dec 5, 2016).
Related to the lately merged #5689, It seems like I stumbled on an edge case where undesired conflicts where introduced.
I've an object order with many-to-one relations to parcels and items.
Both many-to-one relations are set-up with cascade-merge, while the owning sides are not set-up for cascade-merge. In the merge operation, new items are persisted as well.
If the owning side is not setup for cascade-merge, proxies are generated for the owning side on mergeEntityStateIntoManagedCopy and later replaced with the correct order object. These proxies are registered as managed, but never deleted.
Since the reference is thrown away immediately after merge, this leaks a spl_object_hash resulting in a collision.
This results in undesired side effects like inserting wrong ids on flush into the database.
The problem can be solved by defining the owning side as cascade-merge as well.
I'll provide a test for it later this week.
I'd like to contribute with a fix as well. I think, we could just update the state of the parent entity prior to cascadeMerge. I haven't found yet, where it's done currently.
With kind regards