Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-188

Collections are not hydrated properly

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      The following example has User and Address entities, where User has many Addresses (ArrayCollection).

      http://pastebin.com/f1f065cb0

      $u = $em->find('Entity\User', $id);
      $addresses = $u->getAddresses();
      foreach ($addresses as $a) { }  // This line breaks!
      

      The script runs until the foreach loop, then it breaks with a fatal error:

      PHP Notice:  Undefined variable: owningAssoc in /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Persist
      ers/StandardEntityPersister.php on line 545
      PHP Fatal error:  Uncaught exception 'Doctrine\ORM\ORMException' with message 'Unrecognized field: user
      Id' in /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/ORMException.php:14
      Stack trace:
      #0 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php(660): Doctrin
      e\ORM\ORMException::unrecognizedField('userId')
      #1 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php(545): Doctrin
      e\ORM\Persisters\StandardEntityPersister->_getSelectEntitiesSql(Array, NULL)
      #2 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Mapping/OneToManyMapping.php(133): Doctrine\ORM\Pers
      isters\StandardEntityPersister->loadOneToManyCollection(Array, Object(Doctrine\ORM\PersistentCollection
      ))
      #3 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/PersistentCollection.php(244): Doctrine\ORM\Mapping\
      OneToManyMapping->load(Object(Entity\User), Object(Doctrine\ORM\PersistentCollection), Object(Doctrine\
      ORM\EntityManager))
      #4 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/PersistentCollection.php(549): Doc in /home/kaiser/d
      octrine/doctrine/lib/Doctrine/ORM/ORMException.php on line 14
      

      If I uncomment the user creation code in my pastebin example (i.e. create User, Address first), it works as expected (assumingly because everything is in the EM already).

      So this bug probably breaks all select-only use cases with collections (which makes it a Blocker in my opinion).

        Activity

        Nico Kaiser created issue -
        Nico Kaiser made changes -
        Field Original Value New Value
        Description The following example has *User* and *Address* entities, where *User* has many *Addresses* (ArrayCollection).

        http://pastebin.com/d540a309b

        {noformat}
        $u = $em->find('Entity\User', $id);
        $addresses = $u->getAddresses();
        foreach ($addresses as $a) { } // This line breaks!
        {noformat}

        The script runs until the foreach loop, then it breaks with a fatal error:

        {noformat}
        PHP Notice: Undefined variable: owningAssoc in /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Persist
        ers/StandardEntityPersister.php on line 545
        PHP Fatal error: Uncaught exception 'Doctrine\ORM\ORMException' with message 'Unrecognized field: user
        Id' in /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/ORMException.php:14
        Stack trace:
        #0 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php(660): Doctrin
        e\ORM\ORMException::unrecognizedField('userId')
        #1 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php(545): Doctrin
        e\ORM\Persisters\StandardEntityPersister->_getSelectEntitiesSql(Array, NULL)
        #2 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Mapping/OneToManyMapping.php(133): Doctrine\ORM\Pers
        isters\StandardEntityPersister->loadOneToManyCollection(Array, Object(Doctrine\ORM\PersistentCollection
        ))
        #3 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/PersistentCollection.php(244): Doctrine\ORM\Mapping\
        OneToManyMapping->load(Object(Entity\User), Object(Doctrine\ORM\PersistentCollection), Object(Doctrine\
        ORM\EntityManager))
        #4 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/PersistentCollection.php(549): Doc in /home/kaiser/d
        octrine/doctrine/lib/Doctrine/ORM/ORMException.php on line 14
        {noformat}

        If I uncomment the user creation code in my pastebin example (i.e. create User, Address first), it works as expected (assumingly because everything is in the EM already).

        So this bug probably breaks all select-only use cases with collections (which makes it a Blocker in my opinion).
        The following example has *User* and *Address* entities, where *User* has many *Addresses* (ArrayCollection).

        http://pastebin.com/f1f065cb0

        {noformat}
        $u = $em->find('Entity\User', $id);
        $addresses = $u->getAddresses();
        foreach ($addresses as $a) { } // This line breaks!
        {noformat}

        The script runs until the foreach loop, then it breaks with a fatal error:

        {noformat}
        PHP Notice: Undefined variable: owningAssoc in /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Persist
        ers/StandardEntityPersister.php on line 545
        PHP Fatal error: Uncaught exception 'Doctrine\ORM\ORMException' with message 'Unrecognized field: user
        Id' in /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/ORMException.php:14
        Stack trace:
        #0 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php(660): Doctrin
        e\ORM\ORMException::unrecognizedField('userId')
        #1 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php(545): Doctrin
        e\ORM\Persisters\StandardEntityPersister->_getSelectEntitiesSql(Array, NULL)
        #2 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Mapping/OneToManyMapping.php(133): Doctrine\ORM\Pers
        isters\StandardEntityPersister->loadOneToManyCollection(Array, Object(Doctrine\ORM\PersistentCollection
        ))
        #3 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/PersistentCollection.php(244): Doctrine\ORM\Mapping\
        OneToManyMapping->load(Object(Entity\User), Object(Doctrine\ORM\PersistentCollection), Object(Doctrine\
        ORM\EntityManager))
        #4 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/PersistentCollection.php(549): Doc in /home/kaiser/d
        octrine/doctrine/lib/Doctrine/ORM/ORMException.php on line 14
        {noformat}

        If I uncomment the user creation code in my pastebin example (i.e. create User, Address first), it works as expected (assumingly because everything is in the EM already).

        So this bug probably breaks all select-only use cases with collections (which makes it a Blocker in my opinion).
        Hide
        Roman S. Borschel added a comment -

        Hm, this is dubious as this is directly and indirectly tested all over the place.

        I was unable to reproduce it as of yet. Will keep you updated.

        Show
        Roman S. Borschel added a comment - Hm, this is dubious as this is directly and indirectly tested all over the place. I was unable to reproduce it as of yet. Will keep you updated.
        Hide
        Roman S. Borschel added a comment -

        Are you sure you dont have local modifications? The notice looks suspicious and _getSelectEntitiesSql(Array, NULL) does not look correct either. The association should be passed in.

        Show
        Roman S. Borschel added a comment - Are you sure you dont have local modifications? The notice looks suspicious and _getSelectEntitiesSql(Array, NULL) does not look correct either. The association should be passed in.
        Hide
        Roman S. Borschel added a comment -

        Your patch in DDC-162 is what breaks it.

        Show
        Roman S. Borschel added a comment - Your patch in DDC-162 is what breaks it.
        Roman S. Borschel made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Roman S. Borschel made changes -
        Status In Progress [ 3 ] Open [ 1 ]
        Benjamin Eberlei made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Invalid [ 6 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 10545 ] jira-feedback [ 14191 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback [ 14191 ] jira-feedback2 [ 16055 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 16055 ] jira-feedback3 [ 18308 ]

        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=DDC-188, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Roman S. Borschel
            Reporter:
            Nico Kaiser
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: