doctrine/mongodb-odm — pull request #909 by kimlai (2014-06-24 21:45:38+00:00)
Title: Fix cascade persist for associations.

This PR is somewhat related to https://github.com/doctrine/mongodb-odm/issues/715 I think (the last comment at least).

During a cascade persist operation on a *Many* association, a snapshot of the associated collection is [taken](https://github.com/doctrine/mongodb-odm/blob/master/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L473), marking the collection as "not dirty". So if items were added to the collection before persisting, and the
collection was never initialized, the items are lost (persisted in DB but not present in the instanciated collection anymore).

By using the previously taken snapshot during the collection initialization, we can re-add the lost items after loading the collection.

That's the first time I take a look at Doctrine's internals, so I very well might be completely off with the solution, but I think the use case really is bugged. Or did I miss something ?