After an update of some Symfony 2 bundles I suddenly got this error spl_object_hash() expects parameter 1 to be object, null given
. It has happened before though everytime it is quite an adventure to debug this.
It happens the moment $em->persist($ra)
is invoked only when the type of the $entity
is Bla\OrmBundle\Entity\TapApplianceComponent
. To me the values the $ra
object is containing look valid.
Any ideas?
$ra->getLocation()->addComponent($entity);
$entity->setLocation($ra->getLocation());
switch (get_class($entity)) {
case 'Bla\OrmBundle\Entity\TapApplianceComponent':
$ra->getTapsAndAppliances()->addTapApplianceComponent($entity);
$entity->setTapsAndAppliances($ra->getTapsAndAppliances());
break;
default:
}
$em->persist($ra);
$em->persist($entity);
$em->flush();
I got a stacktrace like bellow:
exception 'PHPUnit_Framework_Error_Warning' with message 'spl_object_hash() expects parameter 1 to be object, null given' in C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php:1602
Stack trace:
#0 [internal function]: PHPUnit_Util_ErrorHandler::handleError(2, 'spl_object_hash...', 'C:\\xampp\\htdocs...', 1602, Array)
#1 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(1602): spl_object_hash(NULL)
#2 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(2219): Doctrine\ORM\UnitOfWork->doPersist(NULL, Array)
#3 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(1645): Doctrine\ORM\UnitOfWork->cascadePersist(Object(Bla\OrmBundle\Entity\TapApplianceComponent), Array)
#4 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(2219): Doctrine\ORM\UnitOfWork->doPersist(Object(Bla\OrmBundle\Entity\TapApplianceComponent), Array)
#5 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(1645): Doctrine\ORM\UnitOfWork->cascadePersist(Object(Bla\OrmBundle\Entity\TapsAndAppliances), Array)
#6 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(2224): Doctrine\ORM\UnitOfWork->doPersist(Object(Bla\OrmBundle\Entity\TapsAndAppliances), Array)
#7 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(1645): Doctrine\ORM\UnitOfWork->cascadePersist(Object(Bla\OrmBundle\Entity\AutoRa), Array)
#8 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(1583): Doctrine\ORM\UnitOfWork->doPersist(Object(Bla\OrmBundle\Entity\AutoRa), Array)
#9 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php(546): Doctrine\ORM\UnitOfWork->persist(Object(Bla\OrmBundle\Entity\AutoRa))
#10 C:\xampp\htdocs\TestServer\src\Bla\ApiBundle\Controller\DefaultController.php(217): Doctrine\ORM\EntityManager->persist(Object(Bla\OrmBundle\Entity\AutoRa))
#11 [internal function]: Bla\ApiBundle\Controller\DefaultController->postComponentAction(Object(Symfony\Component\HttpFoundation\Request), '1')
#12 C:\xampp\htdocs\TestServer\app\bootstrap.php.cache(3008): call_user_func_array(Array, Array)
#13 C:\xampp\htdocs\TestServer\app\bootstrap.php.cache(2970): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#14 C:\xampp\htdocs\TestServer\app\bootstrap.php.cache(3119): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 C:\xampp\htdocs\TestServer\app\bootstrap.php.cache(2364): Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 C:\xampp\htdocs\TestServer\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Client.php(81): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#17 C:\xampp\htdocs\TestServer\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Client.php(111): Symfony\Component\HttpKernel\Client->doRequest(Object(Symfony\Component\HttpFoundation\Request))
#18 C:\xampp\htdocs\TestServer\vendor\symfony\symfony\src\Symfony\Component\BrowserKit\Client.php(327): Symfony\Bundle\FrameworkBundle\Client->doRequest(Object(Symfony\Component\HttpFoundation\Request))
#19 C:\xampp\htdocs\TestServer\src\Bla\ApiBundle\Tests\Controller\ComponentControllerTest.php(57): Symfony\Component\BrowserKit\Client->request('POST', '/api2/analyses/...', Array, Array, Array)
#20 [internal function]: Bla\ApiBundle\Tests\Controller\ComponentControllerTest->testPostIssueES862()
#21 C:\xampp\htdocs\TestServer\vendor\phpunit\phpunit\src\Framework\TestCase.php(962): ReflectionMethod->invokeArgs(Object(Bla\ApiBundle\Tests\Controller\ComponentControllerTest), Array)
#22 C:\xampp\htdocs\TestServer\vendor\phpunit\phpunit\src\Framework\TestCase.php(826): PHPUnit_Framework_TestCase->runTest()
#23 C:\xampp\htdocs\TestServer\vendor\phpunit\phpunit\src\Framework\TestResult.php(686): PHPUnit_Framework_TestCase->runBare()
#24 C:\xampp\htdocs\TestServer\vendor\phpunit\phpunit\src\Framework\TestCase.php(760): PHPUnit_Framework_TestResult->run(Object(Bla\ApiBundle\Tests\Controller\ComponentControllerTest))
#25 C:\xampp\htdocs\TestServer\vendor\phpunit\phpunit\src\Framework\TestSuite.php(699): PHPUnit_Framework_TestCase->run(Object(PHPUnit_Framework_TestResult))
#26 C:\xampp\htdocs\TestServer\vendor\phpunit\phpunit\src\Framework\TestSuite.php(699): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
#27 C:\xampp\htdocs\TestServer\vendor\phpunit\phpunit\src\TextUI\TestRunner.php(426): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
#28 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(176): PHPUnit_TextUI_TestRunner->doRun(Object(NetBeansSuite), Array)
#29 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(129): PHPUnit_TextUI_Command->run(Array, true)
#30 C:\xampp\php\phpunit(46): PHPUnit_TextUI_Command::main()