mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3343: PersistentCollection::removeElement schedules an entity for deletion when relationship is EXTRA_LAZY, with orphanRemoval false.
#4133
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 (Oct 9, 2014).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user asprega:
Given the following entity for which I only report the relevant association:
and its inverse
I experience a weird issue when, inside
Group, I call$this->users->removeElement($user): Doctrine schedules the $user entity for deletion, no matter what (it doesn't check for theorphanRemovalattribute). Also, even re-adding the entity to a newGroupbefore theflush()occurs doesn't prevent it from being deleted.I believe this is a bug, since I do not see any special mention of this behavior in the documentation for extra lazy associations:
http://doctrine-orm.readthedocs.org/en/latest/tutorials/extra-lazy-associations.html.
The workaround for me has been to remove
fetch="EXTRA_LAZY"from the relationship.After digging a little bit into the source code, this seems to be the commit (and the line) that introduced this behavior:
356f5874bf (diff-108586f774fc8acb02163ed709e05e86R403)I also found this on Google:
https://groups.google.com/forum/#!topic/doctrine-user/cx_yBuoqiAE
which basically didn't help much, except for suggesting that it should be a feature when there is an orphanRemoval and/or a cascade operation in place (and that makes perfectly sense).
I set this to "critical" since (as it occurred to me) it can lead to irrecoverable data loss.
Is this effectively a bug?
@doctrinebot commented on GitHub (Oct 9, 2014):
@doctrinebot commented on GitHub (Jan 25, 2015):
Comment created by @ocramius:
Fixed via DDC-3536 and DDC-3537
@doctrinebot commented on GitHub (Jan 25, 2015):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Sep 2, 2015):
Comment created by thinkscape:
Thanks!