Skip to content

Loading…

DDC-2895: [GH-902] Fix Lifecycle Callbacks #3652

Closed
doctrinebot opened this Issue · 2 comments

2 participants

@doctrinebot

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of gwagner:

Url: #902

Message:

Remove a bit of code that breaks lifecycle callbacks of parent MappedSuperclasses

Lets say we are working with this code:

/****
 * @MappedSuperclass
 */
abstract class BaseClass
{
    /****
     * @ORM\Column(name="last_modified", type="datetimetz", nullable=false)
     * @var \DateTime
     */
    protected $lastModified;

    /****
     * @ORM\PrePersist
     * @ORM\PreUpdate
     */
    public function setLastModifiedPreUpdate()
    {
        $this->setLastModified(new \DateTime());
    }

    /****
     * @param \DateTime $lastModified
     */
    public function setLastModified( $lastModified )
    {
        $this->lastModified = $lastModified;
    }

    /****
     * @return \DateTime
     */
    public function getLastModified()
    {
        return $this->lastModified;
    }
}

/****
 * Class MyClass
 *
 * @Entity
 * @HasLifecycleCallbacks
 */
class MyClass extends BaseClass
{
    // Whatever you want in here
}

And you want to save MyClass and have it call the Lifecycle callbacks for your BaseClass. If you leave things they way they are programmed today, the BaseClass will never get its callbacks registered.

By removing the little bit of code there [Lines 472-475], you now get lifecycle callbacks through the entire stack, not just the top most class.

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-902] was closed:
#902

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.4.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.