[MODM-49] Getting PHP notice and warning with empty persistent collection Created: 17/Aug/10  Updated: 17/Aug/10  Resolved: 17/Aug/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: Collections
Affects Version/s: None
Fix Version/s: 1.0.0BETA1

Type: Bug Priority: Major
Reporter: Vladimir Razuvaev Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
Labels: None


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

Comment by Jonathan H. Wage [ 17/Aug/10 ]

This is fixed now.

Generated at Wed Nov 25 03:15:36 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.