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

        Vladimir Razuvaev created issue -
        Hide
        Jonathan H. Wage added a comment -

        This is fixed now.

        Show
        Jonathan H. Wage added a comment - This is fixed now.
        Jonathan H. Wage made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.0.0BETA1 [ 10080 ]
        Resolution Fixed [ 1 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=MODM-49, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

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

            Dates

            • Created:
              Updated:
              Resolved: