Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-3218

Argument 3 passed to Doctrine\ORM\Event\PreUpdateEventArgs::__construct() must be of the type array, null given

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.4.2, 2.4.4
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      Linux / Mint 15
      php 5.5.*

      Description

      Argument 3 passed to Doctrine\ORM\Event\PreUpdateEventArgs::__construct() must be of the type array, null given, called in /home/greg/dev/product/insight/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 1009 and defined

      Stack trace:

      [1] PHPUnit_Framework_Error: Argument 3 passed to Doctrine\ORM\Event\PreUpdateEventArgs::__construct() must be of the type array, null given, called in /project/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 1009 and defined
      at n/a
      in /project/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php line 47

      at PHPUnit_Util_ErrorHandler::handleError('4096', 'Argument 3 passed to Doctrine\ORM\Event\PreUpdateEventArgs::__construct() must be of the type array, null given, called in /project/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 1009 and defined', '/project/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php', '47', array('entity' => object(Violation), 'em' => object(EntityManager)))
      in /project/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php line 47

      at Doctrine\ORM\Event\PreUpdateEventArgs->__construct(object(Violation), object(EntityManager), null)
      in /project/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 1009

      at Doctrine\ORM\UnitOfWork->executeUpdates(object(ClassMetadata))
      in /project/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 341

      at Doctrine\ORM\UnitOfWork->commit(null)
      in /project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php line 389

      at Doctrine\ORM\EntityManager->flush()
      in /project/src/SensioLabs/Bundle/MyBundle/Controller/MyController.php line 127

      at SensioLabs\Bundle\MyBundle\Controller\MyController->ignoreAction(object(Request), object(Project), object(Analysis), '4')
      in line

      at call_user_func_array(array(object(MyController), 'ignoreAction'), array(object(Request), object(Project), object(Analysis), '4'))
      in /project/app/bootstrap.php.cache line 1043

      at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
      in /project/app/bootstrap.php.cache line 1015

      at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
      in /project/app/bootstrap.php.cache line 1154

      at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
      in /project/app/bootstrap.php.cache line 435

      at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
      in /project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Client.php line 81

      at Symfony\Component\HttpKernel\Client->doRequest(object(Request))
      in /project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Client.php line 111

      at Symfony\Bundle\FrameworkBundle\Client->doRequest(object(Request))
      in /project/vendor/symfony/symfony/src/Symfony/Component/BrowserKit/Client.php line 319

      at Symfony\Component\BrowserKit\Client->request('POST', '/projects/id-foo/analyses/2/rule/4/ignore', array('ignore_rule' => array('comment' => 'Message about why this rule has been ignored', '_token' => 'CxEFTSv4GZQSWYXtRt-eHybaML4z8I0WK1DHiwr8Ih0')))
      in /project/src/SensioLabs/Bundle/MyBundle/Test/Client.php line 489

      at SensioLabs\Bundle\MyBundle\Test\Client->ignoreRuleViolations('id-foo', '2', '4', false)
      in /project/src/SensioLabs/Bundle/MyBundle/Tests/Acceptance/ViolationCommentsTest.php line 217

      at SensioLabs\Bundle\MyBundle\Tests\Acceptance\ViolationCommentsTest->testDashboardWithCriticalIgnoredRules()
      in line

      at ReflectionMethod->invokeArgs(object(ViolationCommentsTest), array())
      in /project/vendor/phpunit/phpunit/src/Framework/TestCase.php line 951

      at PHPUnit_Framework_TestCase->runTest()
      in /project/vendor/phpunit/phpunit/src/Framework/TestCase.php line 817

      at PHPUnit_Framework_TestCase->runBare()
      in /project/vendor/phpunit/phpunit/src/Framework/TestResult.php line 686

      at PHPUnit_Framework_TestResult->run(object(ViolationCommentsTest))
      in /project/vendor/phpunit/phpunit/src/Framework/TestCase.php line 753

      at PHPUnit_Framework_TestCase->run(object(PHPUnit_Framework_TestResult))
      in /project/vendor/phpunit/phpunit/src/Framework/TestSuite.php line 675

      at PHPUnit_Framework_TestSuite->run(object(PHPUnit_Framework_TestResult))
      in /project/vendor/phpunit/phpunit/src/TextUI/TestRunner.php line 426

      at PHPUnit_TextUI_TestRunner->doRun(object(PHPUnit_Framework_TestSuite), array('listGroups' => false, 'loader' => null, 'useDefaultConfiguration' => true, 'configuration' => '/project/app/phpunit.xml.dist', 'filter' => 'testDashboardWithCriticalIgnoredRules', 'testSuffixes' => array('Test.php', '.phpt')))
      in /opt/dotfiles/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php line 176

      at PHPUnit_TextUI_Command->run(array('/usr/local/bin/phpunit', 'c', 'app/', '-filter', 'testDashboardWithCriticalIgnoredRules', 'src/SensioLabs/Bundle/MyBundle/Tests/Acceptance/ViolationCommentsTest.php'), true)
      in /opt/dotfiles/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php line 129

      at PHPUnit_TextUI_Command::main()
      in /opt/dotfiles/vendor/phpunit/phpunit/composer/bin/phpunit line 63

      I fails in this code

          private function executeUpdates($class)
          {
              $className          = $class->name;
              $persister          = $this->getEntityPersister($className);
              $preUpdateInvoke    = $this->listenersInvoker->getSubscribedSystems($class, Events::preUpdate);
              $postUpdateInvoke   = $this->listenersInvoker->getSubscribedSystems($class, Events::postUpdate);
      
              foreach ($this->entityUpdates as $oid => $entity) {
                  if ($this->em->getClassMetadata(get_class($entity))->name !== $className) {
                      continue;
                  }
      
                  if ($preUpdateInvoke != ListenersInvoker::INVOKE_NONE) {
      // => this line
                      $this->listenersInvoker->invoke($class, Events::preUpdate, $entity, new PreUpdateEventArgs($entity, $this->em, $this->entityChangeSets[$oid]), $preUpdateInvoke);
                      $this->recomputeSingleEntityChangeSet($class, $entity);
                  }
      
                  if ( ! empty($this->entityChangeSets[$oid])) {
                      $persister->update($entity);
                  }
      
                  unset($this->entityUpdates[$oid]);
      
                  if ($postUpdateInvoke != ListenersInvoker::INVOKE_NONE) {
                      $this->listenersInvoker->invoke($class, Events::postUpdate, $entity, new LifecycleEventArgs($entity, $this->em), $postUpdateInvoke);
                  }
              }
          }
      

        Activity

        Hide
        Marco Pivetta added a comment -

        Requires a test case

        Show
        Marco Pivetta added a comment - Requires a test case
        Hide
        Victor added a comment - - edited

        I have same bug when call flush() method from entity manager in my few event listeners in Symfony.

        P.S. If I call flush() only from one listener - it works well, but when call flush() in first, and then in second - it fails. And it does not matter in which order listeners are called.

        Show
        Victor added a comment - - edited I have same bug when call flush() method from entity manager in my few event listeners in Symfony. P.S. If I call flush() only from one listener - it works well, but when call flush() in first, and then in second - it fails. And it does not matter in which order listeners are called.
        Hide
        Grégoire Pineau added a comment -

        yeah, the bug occurs in the same circumstance as described by victor.
        (sorry for the delay, and sorry to not provider a test case)

        Show
        Grégoire Pineau added a comment - yeah, the bug occurs in the same circumstance as described by victor. (sorry for the delay, and sorry to not provider a test case)
        Hide
        Christophe Coevoet added a comment -

        Calling flush() inside a Doctrine listener is not a supported Doctrine usage. it means you are trying to nest several flushes inside each other, which can indeed break the unit of work

        Show
        Christophe Coevoet added a comment - Calling flush() inside a Doctrine listener is not a supported Doctrine usage. it means you are trying to nest several flushes inside each other, which can indeed break the unit of work
        Hide
        Grégoire Pineau added a comment -

        I refactored this part of our code base, to remove all flush from the listener. Everything works right now.
        But I did not know this was not possible. (And it's not me the guy who created this **** in our codebase )

        Show
        Grégoire Pineau added a comment - I refactored this part of our code base, to remove all flush from the listener. Everything works right now. But I did not know this was not possible. (And it's not me the guy who created this **** in our codebase )
        Hide
        Victor added a comment - - edited

        So, for example, if I use postUpdate Doctrine event to modify the entity after save them to DB, I can't save additional changes to DB again with flush() in my listener?
        Is it will be fixed or it's a normal behavior of Doctrine?

        Show
        Victor added a comment - - edited So, for example, if I use postUpdate Doctrine event to modify the entity after save them to DB, I can't save additional changes to DB again with flush() in my listener? Is it will be fixed or it's a normal behavior of Doctrine?

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Grégoire Pineau
          • Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated: