Error when trying to edit comments and have CSRF disabled in Symfony 3
victorbstan opened this issue · 0 comments
victorbstan commented
I have a symfony project using the comments bundle, and when I disable CSRF protection, the form crashes when trying to edit a comment, with this error:
Type error: Argument 1 passed to Symfony\Component\Form\FormRenderer::searchAndRenderBlock() must be an instance of Symfony\Component\Form\FormView, null given, called in /var/www/my-app/var/cache/dev/twig/8c/8c423f2d7652ec479572a3b9d6d73f7f76a1eca9cc3128ea941de61b6c9fc616.php on line 98 (500 Internal Server Error)
If I re-enable csrf protection in symfony it works again.
I would like to disable CSRF in symfony configuration ...
framework
csrf_protection: false
... and comment editing should still work.
Full stack trace:
[1] Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to Symfony\Component\Form\FormRenderer::searchAndRenderBlock() must be an instance of Symfony\Component\Form\FormView, null given, called in /var/www/my-app-suite/var/cache/dev/twig/8c/8c423f2d7652ec479572a3b9d6d73f7f76a1eca9cc3128ea941de61b6c9fc616.php on line 98
at n/a
in /var/www/my-app-suite/vendor/symfony/symfony/src/Symfony/Component/Form/FormRenderer.php line 154
at Symfony\Component\Form\FormRenderer->searchAndRenderBlock(null, 'widget')
in /var/www/my-app-suite/var/cache/dev/twig/8c/8c423f2d7652ec479572a3b9d6d73f7f76a1eca9cc3128ea941de61b6c9fc616.php line 98
at __TwigTemplate_b45b4e937118d0f9416f3132687504f024cec8079b9affcb11f0af6237587b9a->block_fos_comment_form_fields(array('form' => object(FormView), 'comment' => object(Comment), 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'ga_token' => 'x', 'x' => 'x', 'raygun_token' => 'x', 'form_keep_feedback_url' => 'x', 'webroot' => '/x/../web', 'auth0_domain' => 'rg-lms.x', 'x' => 'x', 'auth0_connection' => 'tes-dev', 'x' => 'x', 'lms_sso_url' => 'my-app-apps.x/authorize?x=x&response_type=code&redirect_uri=x', 'x_url' => 'my-app-apps.x/authorize?x=x&response_type=code&redirect_uri=my-app.x.com/hc/', 'x_team_lead_guide_url' => 'my-app.x.com/x', 'x_team_member_guide_url' => 'my-app.x.com/x', 'sonata_block' => object(GlobalVariables), 'sonata_admin' => object(GlobalVariables)), array('fos_comment_form_fields' => array(object(__TwigTemplate_b45b4e937118d0f9416f3132687504f024cec8079b9affcb11f0af6237587b9a), 'block_fos_comment_form_fields'), 'fos_comment_form_submit' => array(object(__TwigTemplate_b45b4e937118d0f9416f3132687504f024cec8079b9affcb11f0af6237587b9a), 'block_fos_comment_form_submit')))
in /var/www/my-app-suite/vendor/twig/twig/lib/Twig/Template.php line 215
at Twig_Template->displayBlock('fos_comment_form_fields', array('form' => object(FormView), 'comment' => object(Comment), 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'ga_token' => 'x', 'x' => 'x', 'raygun_token' => 'x', 'form_keep_feedback_url' => 'x', 'webroot' => '/x/../web', 'auth0_domain' => 'rg-lms.x', 'x' => 'x', 'auth0_connection' => 'tes-dev', 'x' => 'x', 'lms_sso_url' => 'my-app-apps.x/authorize?x=x&response_type=code&redirect_uri=x', 'x_url' => 'my-app-apps.x/authorize?x=x&response_type=code&redirect_uri=my-app.x.com/hc/', 'x_team_lead_guide_url' => 'my-app.x.com/x', 'x_team_member_guide_url' => 'my-app.x.com/x', 'sonata_block' => object(GlobalVariables), 'sonata_admin' => object(GlobalVariables)), array('fos_comment_form_fields' => array(object(__TwigTemplate_b45b4e937118d0f9416f3132687504f024cec8079b9affcb11f0af6237587b9a), 'block_fos_comment_form_fields'), 'fos_comment_form_submit' => array(object(__TwigTemplate_b45b4e937118d0f9416f3132687504f024cec8079b9affcb11f0af6237587b9a), 'block_fos_comment_form_submit')))
in /var/www/my-app-suite/var/cache/dev/twig/8c/8c423f2d7652ec479572a3b9d6d73f7f76a1eca9cc3128ea941de61b6c9fc616.php line 39
at __TwigTemplate_b45b4e937118d0f9416f3132687504f024cec8079b9affcb11f0af6237587b9a->doDisplay(array('form' => object(FormView), 'comment' => object(Comment), 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'ga_token' => 'x', 'x' => 'x', 'raygun_token' => 'x', 'form_keep_feedback_url' => 'x', 'webroot' => '/x/../web', 'auth0_domain' => 'rg-lms.x', 'x' => 'x', 'auth0_connection' => 'tes-dev', 'x' => 'x', 'lms_sso_url' => 'my-app-apps.x/authorize?x=x&response_type=code&redirect_uri=x', 'x_url' => 'my-app-apps.x/authorize?x=x&response_type=code&redirect_uri=my-app.x.com/hc/', 'x_team_lead_guide_url' => 'my-app.x.com/x', 'x_team_member_guide_url' => 'my-app.x.com/x', 'sonata_block' => object(GlobalVariables), 'sonata_admin' => object(GlobalVariables)), array('fos_comment_form_fields' => array(object(__TwigTemplate_b45b4e937118d0f9416f3132687504f024cec8079b9affcb11f0af6237587b9a), 'block_fos_comment_form_fields'), 'fos_comment_form_submit' => array(object(__TwigTemplate_b45b4e937118d0f9416f3132687504f024cec8079b9affcb11f0af6237587b9a), 'block_fos_comment_form_submit')))
in /var/www/my-app-suite/vendor/twig/twig/lib/Twig/Template.php line 432
at Twig_Template->displayWithErrorHandling(array('form' => object(FormView), 'comment' => object(Comment), 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'ga_token' => 'x', 'x' => 'x', 'raygun_token' => 'x', 'form_keep_feedback_url' => 'x', 'webroot' => '/x/../web', 'auth0_domain' => 'rg-lms.x', 'x' => 'x', 'auth0_connection' => 'tes-dev', 'x' => 'x', 'lms_sso_url' => 'my-app-apps.x/authorize?x=x&response_type=code&redirect_uri=x', 'x_url' => 'my-app-apps.x/authorize?x=x&response_type=code&redirect_uri=my-app.x.com/hc/', 'x_team_lead_guide_url' => 'my-app.x.com/x', 'x_team_member_guide_url' => 'my-app.x.com/x', 'sonata_block' => object(GlobalVariables), 'sonata_admin' => object(GlobalVariables)), array('fos_comment_form_fields' => array(object(__TwigTemplate_b45b4e937118d0f9416f3132687504f024cec8079b9affcb11f0af6237587b9a), 'block_fos_comment_form_fields'), 'fos_comment_form_submit' => array(object(__TwigTemplate_b45b4e937118d0f9416f3132687504f024cec8079b9affcb11f0af6237587b9a), 'block_fos_comment_form_submit')))
in /var/www/my-app-suite/vendor/twig/twig/lib/Twig/Template.php line 403
at Twig_Template->display(array('form' => object(FormView), 'comment' => object(Comment)))
in /var/www/my-app-suite/vendor/twig/twig/lib/Twig/Template.php line 411
at Twig_Template->render(array('form' => object(FormView), 'comment' => object(Comment)))
in /var/www/my-app-suite/vendor/symfony/symfony/src/Symfony/Bridge/Twig/TwigEngine.php line 50
at Symfony\Bridge\Twig\TwigEngine->render(object(TemplateReference), array('form' => object(FormView), 'comment' => object(Comment)))
in /var/www/my-app-suite/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/TwigEngine.php line 50
at Symfony\Bundle\TwigBundle\TwigEngine->render(object(TemplateReference), array('form' => object(FormView), 'comment' => object(Comment)))
in /var/www/my-app-suite/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 419
at FOS\RestBundle\View\ViewHandler->renderTemplate(object(View), 'html')
in /var/www/my-app-suite/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 494
at FOS\RestBundle\View\ViewHandler->initResponse(object(View), 'html')
in /var/www/my-app-suite/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 473
at FOS\RestBundle\View\ViewHandler->createResponse(object(View), object(Request), 'html')
in /var/www/my-app-suite/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 358
at FOS\RestBundle\View\ViewHandler->handle(object(View))
in /var/www/my-app-suite/vendor/friendsofsymfony/comment-bundle/FOS/CommentBundle/Controller/ThreadController.php line 340
at FOS\CommentBundle\Controller\ThreadController->editThreadCommentAction('privatenotes_644_1033', '359')
in line
at call_user_func_array(array(object(ThreadController), 'editThreadCommentAction'), array('privatenotes_644_1033', '359'))
in /var/www/my-app-suite/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php line 153
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
in /var/www/my-app-suite/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php line 68
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
in /var/www/my-app-suite/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php line 168
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
in /var/www/my-app-suite/web/app_dev.php line 14