Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-3005

Events::postLoad fires without filled associations

    Details

    • Type: Bug Bug
    • Status: Reopened
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      When we load entities throw one dql query like this:

      SELECT e, joined_link FROM Entity LEFT JOIN e.link joined_link
      

      In event subscriber, subscribed to postLoad event for instances of Entity property "link" of entity does not contains fetched in same query joined entity, and does not contains proxy object.

      Tell me if failing test case needed.

        Issue Links

          Activity

          Hide
          Marco Pivetta added a comment - - edited

          To give you some hints, Doctrine\ORM\Events::postLoad is triggered in https://github.com/doctrine/doctrine2/blob/15432fc55f83c2d6ce8d9b86fd3139dd2a4fc328/lib/Doctrine/ORM/UnitOfWork.php#L2788, and Doctrine\ORM\UnitOfWork#createEntity() is used by all the various hydrators internally.

          To ensure that Doctrine\ORM\Events::postLoad is triggered after an entity is fully loaded, the various hydrators must trigger the events after being sure that all data has been set, and that the entity is "ready" for use. That's some copy-paste work :\

          Show
          Marco Pivetta added a comment - - edited To give you some hints, Doctrine\ORM\Events::postLoad is triggered in https://github.com/doctrine/doctrine2/blob/15432fc55f83c2d6ce8d9b86fd3139dd2a4fc328/lib/Doctrine/ORM/UnitOfWork.php#L2788 , and Doctrine\ORM\UnitOfWork#createEntity() is used by all the various hydrators internally. To ensure that Doctrine\ORM\Events::postLoad is triggered after an entity is fully loaded, the various hydrators must trigger the events after being sure that all data has been set, and that the entity is "ready" for use. That's some copy-paste work :\
          Show
          Artur Eshenbrener added a comment - I think the entry point is here: https://github.com/doctrine/doctrine2/blob/15432fc55f83c2d6ce8d9b86fd3139dd2a4fc328/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php#L140 , so, copy-paste work is not needed )
          Hide
          Artur Eshenbrener added a comment -
          Show
          Artur Eshenbrener added a comment - PR is ready: https://github.com/doctrine/doctrine2/pull/1001
          Hide
          Doctrine Bot added a comment -

          A related Github Pull-Request [GH-1001] was assigned:
          https://github.com/doctrine/doctrine2/pull/1001

          Show
          Doctrine Bot added a comment - A related Github Pull-Request [GH-1001] was assigned: https://github.com/doctrine/doctrine2/pull/1001
          Hide
          Doctrine Bot added a comment -

          A related Github Pull-Request [GH-1001] was unassigned:
          https://github.com/doctrine/doctrine2/pull/1001

          Show
          Doctrine Bot added a comment - A related Github Pull-Request [GH-1001] was unassigned: https://github.com/doctrine/doctrine2/pull/1001

            People

            • Assignee:
              Marco Pivetta
              Reporter:
              Artur Eshenbrener
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: