Jira issue originally created by user bschussek:
I'm trying to clone a PersistentCollection and expect to get a stable snapshot. But the class does not implement **clone, thus both objects refer to the same internal ArrayCollection.
I can't use takeSnapshot because I'm writing generic code that should work with any implementation of Traversable/ArrayAccess.
Comment created by @beberlei:
Moved to right project
Comment created by bschussek:
Thank you for moving. Any comments on the feasibility of this issue?
I guess its feasible, i have to think about:
Ok. For the sake of completeness, this issue directly causes another in Symfony2 which was already partially fixed here: symfony/symfony#3315
Comment created by auswebdev:
PR submitted for this issue: #281
What are you doing after the PersistentCollection is cloned?
The reason is, that if the code looks like this:
$col = clone $entity->getCol();
It will do very weird stuff using the owner of the association $col which is $entity. It will also try to insert the $col for $entity not for $otherEntity. To prevent this we have to do some work,
Fixed in 93f79d0 and merged into 2.2 and 2.1.x
Issue was closed with resolution "Fixed"