Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1173

Fatal error when a listener resets an object in onFlush and recompute the changeset

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.5, Git Master
    • Fix Version/s: 2.1
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      When a listener resets an entity during onFlush and recompute the changeset (setting it to null as there is no changes), the following triggering of preUpdate fails as PreUpdateEventArgs would get null as third argument which is forbidden

        Activity

        Hide
        Gediminas Morkevicius added a comment -

        Here is a test case:

        use Doctrine\Common\EventSubscriber;
        use Doctrine\ORM\Event\PreUpdateEventArgs;
        use Doctrine\ORM\Event\OnFlushEventArgs;

        class DummyListener implements EventSubscriber
        {
        public function getSubscribedEvents()

        { return array('preUpdate', 'onFlush'); }

        public function onFlush(OnFlushEventArgs $args)
        {
        $uow = $args->getEntityManager()->getUnitOfWork();
        foreach ($uow->getScheduledEntityUpdates() as $object)

        { $uow->clearEntityChangeSet(spl_object_hash($object)); }

        }

        public function preUpdate(PreUpdateEventArgs $args)

        { var_dump('invoked'); }

        }

        triggers fatal error

        Show
        Gediminas Morkevicius added a comment - Here is a test case: use Doctrine\Common\EventSubscriber; use Doctrine\ORM\Event\PreUpdateEventArgs; use Doctrine\ORM\Event\OnFlushEventArgs; class DummyListener implements EventSubscriber { public function getSubscribedEvents() { return array('preUpdate', 'onFlush'); } public function onFlush(OnFlushEventArgs $args) { $uow = $args->getEntityManager()->getUnitOfWork(); foreach ($uow->getScheduledEntityUpdates() as $object) { $uow->clearEntityChangeSet(spl_object_hash($object)); } } public function preUpdate(PreUpdateEventArgs $args) { var_dump('invoked'); } } triggers fatal error
        Hide
        Benjamin Eberlei added a comment -

        Only fixed in 2.1

        Show
        Benjamin Eberlei added a comment - Only fixed in 2.1

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Christophe Coevoet
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: