mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
flush([$one]) does not flush changes of the $manies (cascade all is set) #6275
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 @dominikzogg on GitHub (Aug 2, 2019).
Bug Report
Summary
We tried to flush the one side and expected that the changes on the manies side are flushed to.
Current behavior
The changes of the manies gets ignored, when the manies already exist in the database.
https://github.com/doctrine/orm/blob/2.6/lib/Doctrine/ORM/UnitOfWork.php#L912
How to reproduce
Create a bidirectional one to many relation. Set cascade to all and add orphanRemoval.
Changes on $one will be flushed, add and remove on manies will be flushed, but not changes.
Expected behavior
Changes on $one will be flushed, add and remove on manies will be flushed, changes on manies will be flushed.
@lcobucci commented on GitHub (Aug 2, 2019):
Flushing specific entities has known issues and is kind of a big pain, hence the removal from v3.
Sorry to frustrate you with this answer but our recommendation is to not rely on that 😕
@dominikzogg commented on GitHub (Aug 2, 2019):
@lcobucci thanks for you fast response. The answer is OK for me.
What we tried:
So you give me another good reason to stop trying todo dirty hacks.
@SenseException commented on GitHub (Aug 14, 2019):
Being able to flush specific entities like
flush($one)won't be able starting with 3.0. You would depend on a different solution if an update to 3.0 happens.https://github.com/doctrine/orm/blob/master/UPGRADE.md#bc-break-removed-entitymanagerflushentity-and-entitymanagerflushentities
@lcobucci commented on GitHub (Oct 1, 2019):
@dominikzogg just
flush()should, in theory, work. Based on your snippet I can't really find a reason why it doesn't. Would you be willing to shoot us a PR with a failing functional test case?@dominikzogg commented on GitHub (Oct 2, 2019):
@lcobucci we're stopped trying to create this hack as mentioned in comment https://github.com/doctrine/orm/issues/7788#issuecomment-517831855 . I suggest to close the issue.