Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrePersist in MappedSuperclass fires multiple times #427

Closed
Bilge opened this issue Oct 10, 2012 · 2 comments
Closed

PrePersist in MappedSuperclass fires multiple times #427

Bilge opened this issue Oct 10, 2012 · 2 comments

Comments

@Bilge
Copy link
Contributor

Bilge commented Oct 10, 2012

A PrePersist function in a MappedSuperclass that is not overridden in the derived class fires three times instead of just once. If the subclass does override it, and annotates the function, it is called twice instead of just once. If the subclass does override it but does not annotate it then it is called just once as expected.

/** @MappedSuperclass */
abstract class Super {
    /** @PrePersist */
    public function prePersist() {
        var_dump('Super');
    }
}

class Sub extends Super { }

$dm->persist(new Sub);
$dm->flush(); //Super::prePersist() called 3 times.

#-OR-

class Sub extends Super {
    /** @PrePersist */
    public function prePersist() {
        var_dump('Sub');
    }
}

$dm->persist(new Sub);
$dm->flush(); //Sub::prePersist() called 2 times.

#-OR-

class Sub extends Super {
    public function prePersist() {
        var_dump('Sub');
    }
}

$dm->persist(new Sub);
$dm->flush(); //Sub::prePersist() called once.
@jmikola
Copy link
Member

jmikola commented Jan 9, 2014

HasLifecycleCallbacksTest in #428 will test for this, as we cover all permutations of super/sub classes with @HasLifecycleCallback annotations and overridden methods (8 total). The proper behavior will be for no method to be invoked more than once. That is currently happening in the PR for all but one case (to be fixed) where both the super and sub are annotated and the sub-class overrides the method, too.

@jmikola jmikola closed this as completed in 59a67f3 Jan 9, 2014
@jmikola
Copy link
Member

jmikola commented Jan 9, 2014

#428 is merged, so this should be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants