[DDC-1034] Registered lifecycle callbacks of derived classes have unexpected call sequence Created: 15/Feb/11  Updated: 04/Mar/11  Resolved: 04/Mar/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.0
Fix Version/s: 2.0.2, 2.1
Security Level: All

Type: Bug Priority: Major
Reporter: Bart Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None

Attachments: File TestClasses.php    

 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.



 Comments   
Comment by Benjamin Eberlei [ 04/Mar/11 ]

Fixed.

Generated at Tue Jul 29 11:08:10 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.