mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-1496: OrphanRemove does not work when using clear() without initializing the collection before #1872
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 (Nov 16, 2011).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user georgwaechter:
Collection items (marked with orphanRemoval=true) are not removed from the database correctly if
I think the problem is that PersistentCollection::clear() iterates through the uninitialized collection which is empty in this case. Thus the scheduleOrphanRemoval() method is never called.
The best example is within the doctrine 2 documentation: http://www.doctrine-project.org/docs/orm/2.0/en/reference/working-with-associations.html#orphan-removal . Calling $this->addresses->clear() raises this bug.
I'm currently helping myself by fixing the situation with accessing the elements of the collection before calling ->clear().