Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.0.0BETA1
-
Component/s: Collections
-
Labels:None
Description
If there is an object with empty collection, e.g.:
{
"_id": "4c6a11810f9d503c03000000",
"b": [
]
}
Then following code produces notice and warning:
/** @Document(db="tests", collection="tests") */ class a { /** @Id */ protected $id; /** @ReferenceMany(targetDocument="b", cascade="persist") */ protected $b; function getB() {return $this->b;} } /** @Document(db="tests", collection="tests2") */ class b { /** @Id */ protected $id; } $a = $dm->loadByID('a', '4c6a11810f9d503c03000000'); echo count($a->getB()); // produces notice and warning
Notice and warning text:
Notice: Undefined variable: groupedIds in library\Doctrine\ODM\MongoDB\PersistentCollection.php on line 122
Warning: Invalid argument supplied for foreach() in library\Doctrine\ODM\MongoDB\PersistentCollection.php on line 122
This is fixed now.