Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1034

Registered lifecycle callbacks of derived classes have unexpected call sequence

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0.2, 2.1
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      Situation:
      Create an abstract base class (@InheritanceType("JOINED")) and a derived class, both having the annotation @HasLifecycleCallbacks and both having a method with annotation @PostLoad (different method names). The sequence of methods being called when an object is loaded from the database is not as expected.

      Expected output:
      Called Che\Tmp\BaseClass::PostLoadBase
      Called Che\Tmp\DerivedClass::PostLoadDerived
      (base value, derived value)

      Actual output:
      Called Che\Tmp\BaseClass::PostLoadBase
      Called Che\Tmp\DerivedClass::PostLoadDerived
      Called Che\Tmp\BaseClass::PostLoadBase
      (base value)

      Test code:
      See attachment for classes

      // Assume there is an entity manager $em
      // Create object
      $newDerived = new \Che\Tmp\DerivedClass();
      $em->persist($newDerived);

      // Fetch object
      $derived = $em->findById('\Che\Tmp\DerivedClass', 1);
      $derived->echoList();

      Possible problem cause

      ClassMetadataInfo::addLifecycleCallback($callback, $event) method has a note 'If the same callback is registered more than once, the old one will be overridden'. We are not sure whether this is the case.

        Activity

        Bart created issue -
        Hide
        Benjamin Eberlei added a comment -

        Fixed.

        Show
        Benjamin Eberlei added a comment - Fixed.
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0.2 [ 10116 ]
        Fix Version/s 2.1 [ 10022 ]
        Resolution Fixed [ 1 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 12388 ] jira-feedback [ 14766 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback [ 14766 ] jira-feedback2 [ 16630 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 16630 ] jira-feedback3 [ 18883 ]

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

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Bart
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: