diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index cc73a0e23..b3c84cdba 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -2550,8 +2550,9 @@ class ClassMetadataInfo implements ClassMetadata */ public function addLifecycleCallback($callback, $event) { - if(isset($this->lifecycleCallbacks[$event]) && in_array($callback, $this->lifecycleCallbacks[$event])) + if(isset($this->lifecycleCallbacks[$event]) && in_array($callback, $this->lifecycleCallbacks[$event])) { return; + } $this->lifecycleCallbacks[$event][] = $callback; } diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index 78ea05ea6..79feb2479 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -469,10 +469,10 @@ class AnnotationDriver extends AbstractAnnotationDriver if (isset($classAnnotations['Doctrine\ORM\Mapping\HasLifecycleCallbacks'])) { /* @var $method \ReflectionMethod */ - foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) - { - foreach ($this->getMethodCallbacks($method) as $value) - { + foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method){ + + foreach ($this->getMethodCallbacks($method) as $value) { + $metadata->addLifecycleCallback($value[0], $value[1]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php index 01a6d5c22..5eece3f9b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php @@ -1,13 +1,12 @@