doctrine/mongodb-odm — pull request #692 by spantaleev (2013-10-17 20:40:56+00:00)
Title: Revert "PersistentCollection::count() with ReferenceMany InverseSide map...

...ping queries DB without collection initialization"

This reverts commit bd7d99e290159e310469b0a14aee1aafc7df2381.

Conflicts:
lib/Doctrine/ODM/MongoDB/PersistentCollection.php

Reverting, because not initializing counted incorrectly when:
- the collection has the isInverseSide flag set
- the collection is uninitialized
- has had an item added using add(), making it dirty

Here's the previous (and broken before this commit) flow:
- the collection is inverse-side and not initially initialized
- we add an item via add()
- has the side-effect of marking the collection as dirty
- but still keeps the collection uninitialized
- if count() is called now for this uninitialized inverse-side collection:
- a query gets sent to the database to count the objects
- the result of counting is 0, because:
- there's nothing in the DB yet
(assuming there really was nothing old there for starters)
- nobody cared that $this->coll had some items added to it
and the collection was dirty

The easiest fix I can think of is to restore the old behavior, which
causes initialize() to happen just in case.