mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-1157: Remove Cascade doesn't work on proxy object #1451
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 @doctrinebot on GitHub (May 18, 2011).
Originally assigned to: @guilhermeblanco on GitHub.
Jira issue originally created by user benoit:
Hi all,
I am a beginner with doctrine, so all my apologize if this is not the place, or if this issue was already report. I posted on doctrine user google group(http://tinyurl.com/6gh49yh), but got no response, asked on mirc channel, not response too. I searched into jira for the same issue, but i don't find.
This is my problem: I have a ont-to-one relation between two entities, A and B. A got foreign key to B. I configure delete cascade on A, so i am expected that if A is deleted, B should be too.
I used the Entity Manager getReference method to get an A entity, so this is a proxy object. I did $em->remove($A). After flush, A is remove, but B still alive.
I investigate doctrine source code, and i found in UnitOfWork#cascaseRemove method, line 1705, a TODO comment line, where initialized should call on proxy object. And when remove is called on Proxy object, at this point, $relatedEntities is null.
When i used the Entity Manager find method, i got an object fullfilled, so at this line $relatedEntities is not null.
So this is a forgotten implementation, a bug, or did I make something wrong because what i want to do work perfectly for you ?
Thanks for reading.
@doctrinebot commented on GitHub (Sep 6, 2011):
Comment created by @guilhermeblanco:
Defining delete cascade means that when B is removed, A is also removed... not the opposite.
You need to define cascade={"remove"} in order to have this working nicely.
@doctrinebot commented on GitHub (Sep 6, 2011):
Issue was closed with resolution "Invalid"