Doctrine MongoDB ODM
  1. Doctrine MongoDB ODM
  2. MODM-49

Getting PHP notice and warning with empty persistent collection

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major 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
      

        Activity

        Hide
        Jonathan H. Wage added a comment -

        This is fixed now.

        Show
        Jonathan H. Wage added a comment - This is fixed now.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Vladimir Razuvaev
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: