Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-3079

preUpdate in EntityListener not run in transaction

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 2.4.2
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      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..

        Activity

        Hide
        Marco Pivetta added a comment -

        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

        Show
        Marco Pivetta added a comment - 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

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            Jiri Napravnik
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: