Symfony2表单提交错误(提交前设置关系)
这是我的粘贴:
https://gist.github.com/1026584
上面产生了错误:
Fatal error: method_exists(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Proxies\JStoutMainBundleEntityLocationProxy" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /www/jstout/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php on line 2266 Call Stack: 0.0001 622816 1. {main}() /www/jstout/web/app_dev.php:0 0.0120 1391096 2. Symfony\Component\HttpKernel\Kernel->handle() /www/jstout/web/app_dev.php:21 0.0155 1643168 3. Symfony\Bundle\FrameworkBundle\HttpKernel->handle() /www/jstout/app/bootstrap.php.cache:612 0.0155 1643888 4. Symfony\Component\HttpKernel\HttpKernel->handle() /www/jstout/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/HttpKernel.php:44 0.0155 1643888 5. Symfony\Component\HttpKernel\HttpKernel->handleRaw() /www/jstout/app/bootstrap.php.cache:416 0.0808 3808568 6. call_user_func_array() /www/jstout/app/bootstrap.php.cache:438 0.0808 3808816 7. JStout\MainBundle\Controller\VendorController->signupAction() /www/jstout/app/bootstrap.php.cache:0 0.1496 5248224 8. JStout\MainBundle\Form\Vendor\SignupHandler->process() /www/jstout/src/JStout/MainBundle/Controller/VendorController.php:55 0.1994 6163232 9. Doctrine\ORM\EntityManager->flush() /www/jstout/src/JStout/MainBundle/Form/Vendor/SignupHandler.php:57 0.1994 6163232 10. Doctrine\ORM\UnitOfWork->commit() /www/jstout/vendor/doctrine/lib/Doctrine/ORM/EntityManager.php:328 0.1994 6163232 11. Doctrine\ORM\UnitOfWork->computeChangeSets() /www/jstout/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php:249 0.1998 6187424 12. Doctrine\ORM\UnitOfWork->computeChangeSet() /www/jstout/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php:505 0.2000 6196648 13. Doctrine\ORM\UnitOfWork->computeAssociationChanges() /www/jstout/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php:490 0.2000 6221624 14. Doctrine\ORM\UnitOfWork::objToStr() /www/jstout/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php:572 0.2000 6221752 15. method_exists() /www/jstout/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php:2266
如果删除,错误就会消失:
$vendor->setOwner($user)
这是一个错误还是有一个原因导致我无法将所有者设置为会话对象?
Here's my paste:
https://gist.github.com/1026584
The above produces the error:
Fatal error: method_exists(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Proxies\JStoutMainBundleEntityLocationProxy" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /www/jstout/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php on line 2266 Call Stack: 0.0001 622816 1. {main}() /www/jstout/web/app_dev.php:0 0.0120 1391096 2. Symfony\Component\HttpKernel\Kernel->handle() /www/jstout/web/app_dev.php:21 0.0155 1643168 3. Symfony\Bundle\FrameworkBundle\HttpKernel->handle() /www/jstout/app/bootstrap.php.cache:612 0.0155 1643888 4. Symfony\Component\HttpKernel\HttpKernel->handle() /www/jstout/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/HttpKernel.php:44 0.0155 1643888 5. Symfony\Component\HttpKernel\HttpKernel->handleRaw() /www/jstout/app/bootstrap.php.cache:416 0.0808 3808568 6. call_user_func_array() /www/jstout/app/bootstrap.php.cache:438 0.0808 3808816 7. JStout\MainBundle\Controller\VendorController->signupAction() /www/jstout/app/bootstrap.php.cache:0 0.1496 5248224 8. JStout\MainBundle\Form\Vendor\SignupHandler->process() /www/jstout/src/JStout/MainBundle/Controller/VendorController.php:55 0.1994 6163232 9. Doctrine\ORM\EntityManager->flush() /www/jstout/src/JStout/MainBundle/Form/Vendor/SignupHandler.php:57 0.1994 6163232 10. Doctrine\ORM\UnitOfWork->commit() /www/jstout/vendor/doctrine/lib/Doctrine/ORM/EntityManager.php:328 0.1994 6163232 11. Doctrine\ORM\UnitOfWork->computeChangeSets() /www/jstout/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php:249 0.1998 6187424 12. Doctrine\ORM\UnitOfWork->computeChangeSet() /www/jstout/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php:505 0.2000 6196648 13. Doctrine\ORM\UnitOfWork->computeAssociationChanges() /www/jstout/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php:490 0.2000 6221624 14. Doctrine\ORM\UnitOfWork::objToStr() /www/jstout/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php:572 0.2000 6221752 15. method_exists() /www/jstout/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php:2266
The error goes away if I remove:
$vendor->setOwner($user)
Is this a bug or is there a reason why I can't set the owner to a session object?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 User 对象中有私有属性吗?
在会话中插入对象时会调用php函数serialize,并且私有属性存在问题。您必须将这些私有财产转为受保护。
Do you have private properties in your User object ?
The php function serialize is called when inserting a object in the session, and there are issues with the private properties. You have to swith thse private properties to protected.