Skip to content

Loading…

DDC-1034: Registered lifecycle callbacks of derived classes have unexpected call sequence #1623

Closed
doctrinebot opened this Issue · 3 comments

2 participants

@doctrinebot

Jira issue originally created by user bart:

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.

@doctrinebot

Comment created by @beberlei:

Fixed.

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.0.2 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.