Skip to content


DDC-1496: OrphanRemove does not work when using clear() without initializing the collection before #2124

doctrinebot opened this Issue · 2 comments

2 participants


Jira issue originally created by user georgwaechter:

Collection items (marked with orphanRemoval=true) are not removed from the database correctly if
1. the collection is not initialized
2. we now call ->clear() on it.

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: . 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().


Comment created by @beberlei:

fixed and merged into 2.1.x


Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.1.3 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.