DDC-3079: preUpdate in EntityListener not run in transaction #3821

Closed
opened 2026-01-22 14:28:36 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Apr 10, 2014).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user jirin:

I have entity:

class Article{
    /****
     * @ORM\OneToMany(targetEntity = "ArticleModule\Model\Entities\ArticlePhoto", mappedBy = "article", cascade = {"persist", "remove"}, orphanRemoval = TRUE)
     * @ORM\OrderBy({"sequence" = "ASC"})
     */
    protected $articlePhotos;
}

And Entity Listener with preRemove.

I call

$article->articlePhotos->clear();
...some changes with entity...
$em->flush();

preRemove in Entity Listener is called, BUT before Begin transaction...

I can do
$em->transactional(function(){}); then it's full in transaction..

Originally created by @doctrinebot on GitHub (Apr 10, 2014). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user jirin: I have entity: ``` class Article{ /**** * @ORM\OneToMany(targetEntity = "ArticleModule\Model\Entities\ArticlePhoto", mappedBy = "article", cascade = {"persist", "remove"}, orphanRemoval = TRUE) * @ORM\OrderBy({"sequence" = "ASC"}) */ protected $articlePhotos; } ``` And Entity Listener with preRemove. I call ``` $article->articlePhotos->clear(); ...some changes with entity... $em->flush(); ``` preRemove in Entity Listener is called, BUT before Begin transaction... I can do $em->transactional(function(){}); then it's full in transaction..
admin added the Bug label 2026-01-22 14:28:36 +01:00
admin closed this issue 2026-01-22 14:28:38 +01:00
Author
Owner

@doctrinebot commented on GitHub (Aug 18, 2014):

Comment created by @ocramius:

As of ff80187930/lib/Doctrine/ORM/UnitOfWork.php (L344), I see that preUpdate listeners are executed AFTER the transaction has been started.

Marking as invalid

@doctrinebot commented on GitHub (Aug 18, 2014): Comment created by @ocramius: As of https://github.com/doctrine/doctrine2/blob/ff801879304dfc2bdec34222d4c03fa7bde3e4e4/lib/Doctrine/ORM/UnitOfWork.php#L344, I see that `preUpdate` listeners are executed AFTER the transaction has been started. Marking as invalid
Author
Owner

@doctrinebot commented on GitHub (Aug 18, 2014):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Aug 18, 2014): Issue was closed with resolution "Invalid"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3821