Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep the blocks into the page rendering even if some blocks does not exist #1609

Closed
2 of 3 tasks
Tracked by #1495
eerison opened this issue Sep 12, 2022 · 20 comments
Closed
2 of 3 tasks
Tracked by #1495

Comments

@eerison
Copy link
Contributor

eerison commented Sep 12, 2022

the current code in 3.x and 4.x is crashing the whole page when the block doesn't exist, I faced this issue few months ago, and It should be fixed here.

My idea is, check if the block class still exist, if not log into the logs and jump for the next block to be rendered.

ACs

  • If the block doesn't exist, the page that contain this block must be rendering without this block
  • when try to render a block that doesn't exist, you must log the exception and jump for the next block
  • I should be able to remove any block even if it does't exist.

Note: It's just an example, it can happen with any block that doesn't exist for example, if you rename some block that already exist!

Exception

Twig\Error\RuntimeError:
An exception has been thrown during the rendering of a template ("The block service `sonata.seo.block.email.share_button` does not exist").

  at vendor/sonata-project/page-bundle/src/Resources/views/Block/block_container.html.twig:15
  at Twig\Template->displayBlock('block_child_render', array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content'), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin), '_parent' => array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content'), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), '_seq' => array(object(SonataPageBlock), object(SonataPageBlock), object(SonataPageBlock), object(SonataPageBlock)), 'loop' => array('parent' => array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content'), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), 'index0' => 0, 'index' => 1, 'first' => true, 'revindex0' => 3, 'revindex' => 4, 'length' => 4, 'last' => false), 'child' => object(SonataPageBlock), '_key' => 0), array('block' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block'), 'block_class' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_class'), 'block_role' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_role'), 'block_child_render' => array(object(__TwigTemplate_ee14b3162ccd64b865d6db649e296aee), 'block_block_child_render')))
     (var/cache/dev/twig/a7/a71e2e497387d0ff6dcc6d582691dca1.php:139)
  at __TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f->block_block(array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content'), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin), '_parent' => array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content'), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), '_seq' => array(object(SonataPageBlock), object(SonataPageBlock), object(SonataPageBlock), object(SonataPageBlock)), 'loop' => array('parent' => array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content'), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), 'index0' => 0, 'index' => 1, 'first' => true, 'revindex0' => 3, 'revindex' => 4, 'length' => 4, 'last' => false), 'child' => object(SonataPageBlock), '_key' => 0), array('block' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block'), 'block_class' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_class'), 'block_role' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_role'), 'block_child_render' => array(object(__TwigTemplate_ee14b3162ccd64b865d6db649e296aee), 'block_block_child_render')))
     (vendor/twig/twig/src/Template.php:171)
  at Twig\Template->displayBlock('block', array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content'), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('block' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block'), 'block_class' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_class'), 'block_role' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_role'), 'block_child_render' => array(object(__TwigTemplate_ee14b3162ccd64b865d6db649e296aee), 'block_block_child_render')))
     (var/cache/dev/twig/05/0510d582990bbf1fa7da00c303877039.php:66)
  at __TwigTemplate_d435fb943812d16a601ff59c0a533e59->doDisplay(array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content'), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('block' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block'), 'block_class' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_class'), 'block_role' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_role'), 'block_child_render' => array(object(__TwigTemplate_ee14b3162ccd64b865d6db649e296aee), 'block_block_child_render')))
     (vendor/twig/twig/src/Template.php:394)
  at Twig\Template->displayWithErrorHandling(array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content'), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('block' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block'), 'block_class' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_class'), 'block_role' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_role'), 'block_child_render' => array(object(__TwigTemplate_ee14b3162ccd64b865d6db649e296aee), 'block_block_child_render')))
     (vendor/twig/twig/src/Template.php:367)
  at Twig\Template->display(array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content'), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('block_class' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_class'), 'block_role' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_role'), 'block' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block'), 'block_child_render' => array(object(__TwigTemplate_ee14b3162ccd64b865d6db649e296aee), 'block_block_child_render')))
     (var/cache/dev/twig/a7/a71e2e497387d0ff6dcc6d582691dca1.php:50)
  at __TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f->doDisplay(array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content'), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('block_class' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_class'), 'block_role' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_role'), 'block' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block'), 'block_child_render' => array(object(__TwigTemplate_ee14b3162ccd64b865d6db649e296aee), 'block_block_child_render')))
     (vendor/twig/twig/src/Template.php:394)
  at Twig\Template->displayWithErrorHandling(array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content'), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('block_class' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_class'), 'block_role' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block_role'), 'block' => array(object(__TwigTemplate_ffd0a4617d33634b0a7d9715eed89b7f), 'block_block'), 'block_child_render' => array(object(__TwigTemplate_ee14b3162ccd64b865d6db649e296aee), 'block_block_child_render')))
     (vendor/twig/twig/src/Template.php:367)
  at Twig\Template->display(array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content'), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('block_child_render' => array(object(__TwigTemplate_ee14b3162ccd64b865d6db649e296aee), 'block_block_child_render')))
     (var/cache/dev/twig/ff/ff2bc35fd4f52c62a44b838fef1377e5.php:48)
  at __TwigTemplate_ee14b3162ccd64b865d6db649e296aee->doDisplay(array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content'), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('block_child_render' => array(object(__TwigTemplate_ee14b3162ccd64b865d6db649e296aee), 'block_block_child_render')))
     (vendor/twig/twig/src/Template.php:394)
  at Twig\Template->displayWithErrorHandling(array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content'), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('block_child_render' => array(object(__TwigTemplate_ee14b3162ccd64b865d6db649e296aee), 'block_block_child_render')))
     (vendor/twig/twig/src/Template.php:367)
  at Twig\Template->display(array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content')))
     (vendor/twig/twig/src/Template.php:379)
  at Twig\Template->render(array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content')), array())
     (vendor/twig/twig/src/TemplateWrapper.php:40)
  at Twig\TemplateWrapper->render(array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content')))
     (vendor/twig/twig/src/Environment.php:277)
  at Twig\Environment->render('@SonataPage/Block/block_container.html.twig', array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content')))
     (vendor/sonata-project/block-bundle/src/Block/Service/AbstractBlockService.php:43)
  at Sonata\BlockBundle\Block\Service\AbstractBlockService->renderResponse('@SonataPage/Block/block_container.html.twig', array('block' => object(SonataPageBlock), 'decorator' => array('pre' => '', 'post' => ''), 'settings' => array('layout' => '{{ CONTENT }}', 'class' => '', 'use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => '@SonataPage/Block/block_container.html.twig', 'ttl' => 86400, 'code' => 'content')), object(Response))
     (vendor/sonata-project/page-bundle/src/Block/ContainerBlockService.php:81)
  at Sonata\PageBundle\Block\ContainerBlockService->execute(object(BlockContext), object(Response))
     (vendor/sonata-project/block-bundle/src/Block/BlockRenderer.php:70)
  at Sonata\BlockBundle\Block\BlockRenderer->render(object(BlockContext))
     (vendor/sonata-project/block-bundle/src/Templating/Helper/BlockHelper.php:450)
  at Sonata\BlockBundle\Templating\Helper\BlockHelper->render(object(SonataPageBlock), array())
     (vendor/sonata-project/page-bundle/src/Twig/Extension/PageExtension.php:194)
  at Sonata\PageBundle\Twig\Extension\PageExtension->renderBlock(object(SonataPageBlock), array())
     (vendor/sonata-project/page-bundle/src/Twig/Extension/PageExtension.php:178)
  at Sonata\PageBundle\Twig\Extension\PageExtension->renderContainer('content', object(SnapshotPageProxy))
     (var/cache/dev/twig/ec/ecd8f078e1dd6cf1a7c7a65896ddc021.php:216)
  at __TwigTemplate_2aa42510ab6c10468858721df8069038->block_page_content(array('error_codes' => array('_page_internal_error_not_found', '_page_internal_error_fatal'), 'page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin), 'content' => ''), array('sonata_page_html_tag' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_html_tag'), 'sonata_page_head' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_head'), 'sonata_page_stylesheets' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_stylesheets'), 'sonata_page_javascripts' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_javascripts'), 'sonata_page_body_tag' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_body_tag'), 'sonata_page_top_bar' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_top_bar'), 'sonata_page_container' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_container'), 'sonata_page_asset_footer' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_asset_footer'), 'sonata_page_breadcrumb' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_breadcrumb'), 'page_content' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_page_content')))
     (vendor/twig/twig/src/Template.php:171)
  at Twig\Template->displayBlock('page_content', array('error_codes' => array('_page_internal_error_not_found', '_page_internal_error_fatal'), 'page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('sonata_page_html_tag' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_html_tag'), 'sonata_page_head' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_head'), 'sonata_page_stylesheets' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_stylesheets'), 'sonata_page_javascripts' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_javascripts'), 'sonata_page_body_tag' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_body_tag'), 'sonata_page_top_bar' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_top_bar'), 'sonata_page_container' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_container'), 'sonata_page_asset_footer' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_asset_footer'), 'sonata_page_breadcrumb' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_breadcrumb'), 'page_content' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_page_content')))
     (var/cache/dev/twig/ec/ecd8f078e1dd6cf1a7c7a65896ddc021.php:110)
  at __TwigTemplate_2aa42510ab6c10468858721df8069038->block_sonata_page_container(array('error_codes' => array('_page_internal_error_not_found', '_page_internal_error_fatal'), 'page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('sonata_page_html_tag' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_html_tag'), 'sonata_page_head' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_head'), 'sonata_page_stylesheets' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_stylesheets'), 'sonata_page_javascripts' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_javascripts'), 'sonata_page_body_tag' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_body_tag'), 'sonata_page_top_bar' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_top_bar'), 'sonata_page_container' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_container'), 'sonata_page_asset_footer' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_asset_footer'), 'sonata_page_breadcrumb' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_breadcrumb'), 'page_content' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_page_content')))
     (vendor/twig/twig/src/Template.php:171)
  at Twig\Template->displayBlock('sonata_page_container', array('error_codes' => array('_page_internal_error_not_found', '_page_internal_error_fatal'), 'page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('sonata_page_html_tag' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_html_tag'), 'sonata_page_head' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_head'), 'sonata_page_stylesheets' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_stylesheets'), 'sonata_page_javascripts' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_javascripts'), 'sonata_page_body_tag' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_body_tag'), 'sonata_page_top_bar' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_top_bar'), 'sonata_page_container' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_container'), 'sonata_page_asset_footer' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_asset_footer'), 'sonata_page_breadcrumb' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_breadcrumb'), 'page_content' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_page_content')))
     (var/cache/dev/twig/17/17de26996b008eaa3c0e74715c963c0d.php:69)
  at __TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1->doDisplay(array('error_codes' => array('_page_internal_error_not_found', '_page_internal_error_fatal'), 'page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('sonata_page_html_tag' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_html_tag'), 'sonata_page_head' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_head'), 'sonata_page_stylesheets' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_stylesheets'), 'sonata_page_javascripts' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_javascripts'), 'sonata_page_body_tag' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_body_tag'), 'sonata_page_top_bar' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_top_bar'), 'sonata_page_container' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_container'), 'sonata_page_asset_footer' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_asset_footer'), 'sonata_page_breadcrumb' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_breadcrumb'), 'page_content' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_page_content')))
     (vendor/twig/twig/src/Template.php:394)
  at Twig\Template->displayWithErrorHandling(array('error_codes' => array('_page_internal_error_not_found', '_page_internal_error_fatal'), 'page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('sonata_page_html_tag' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_html_tag'), 'sonata_page_head' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_head'), 'sonata_page_stylesheets' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_stylesheets'), 'sonata_page_javascripts' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_javascripts'), 'sonata_page_body_tag' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_body_tag'), 'sonata_page_top_bar' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_top_bar'), 'sonata_page_container' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_container'), 'sonata_page_asset_footer' => array(object(__TwigTemplate_81babb41dd30e9fbdc438bfadc8a1fc1), 'block_sonata_page_asset_footer'), 'sonata_page_breadcrumb' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_breadcrumb'), 'page_content' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_page_content')))
     (vendor/twig/twig/src/Template.php:367)
  at Twig\Template->display(array('error_codes' => array('_page_internal_error_not_found', '_page_internal_error_fatal'), 'page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('sonata_page_container' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_container'), 'sonata_page_breadcrumb' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_breadcrumb'), 'page_content' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_page_content')))
     (var/cache/dev/twig/ec/ecd8f078e1dd6cf1a7c7a65896ddc021.php:50)
  at __TwigTemplate_2aa42510ab6c10468858721df8069038->doDisplay(array('error_codes' => array('_page_internal_error_not_found', '_page_internal_error_fatal'), 'page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('sonata_page_container' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_container'), 'sonata_page_breadcrumb' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_breadcrumb'), 'page_content' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_page_content')))
     (vendor/twig/twig/src/Template.php:394)
  at Twig\Template->displayWithErrorHandling(array('error_codes' => array('_page_internal_error_not_found', '_page_internal_error_fatal'), 'page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite), 'wrap_fields_with_addons' => true, 'app' => object(AppVariable), 'sonata_block' => object(GlobalVariables), 'sonata_config' => object(SonataConfiguration), 'sonata_page' => object(GlobalVariables), 'sonata_page_admin' => object(PageAdmin)), array('sonata_page_container' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_container'), 'sonata_page_breadcrumb' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_sonata_page_breadcrumb'), 'page_content' => array(object(__TwigTemplate_2aa42510ab6c10468858721df8069038), 'block_page_content')))
     (vendor/twig/twig/src/Template.php:367)
  at Twig\Template->display(array('error_codes' => array('_page_internal_error_not_found', '_page_internal_error_fatal'), 'page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite)))
     (vendor/twig/twig/src/Template.php:379)
  at Twig\Template->render(array('error_codes' => array('_page_internal_error_not_found', '_page_internal_error_fatal'), 'page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite)), array())
     (vendor/twig/twig/src/TemplateWrapper.php:40)
  at Twig\TemplateWrapper->render(array('error_codes' => array('_page_internal_error_not_found', '_page_internal_error_fatal'), 'page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite)))
     (vendor/twig/twig/src/Environment.php:277)
  at Twig\Environment->render('@SonataPage/layout.html.twig', array('error_codes' => array('_page_internal_error_not_found', '_page_internal_error_fatal'), 'page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite)))
     (vendor/sonata-project/page-bundle/src/Page/TemplateManager.php:99)
  at Sonata\PageBundle\Page\TemplateManager->renderResponse('default', array('page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite)), object(Response))
     (vendor/sonata-project/page-bundle/src/Page/Service/DefaultPageService.php:56)
  at Sonata\PageBundle\Page\Service\DefaultPageService->execute(object(SnapshotPageProxy), object(SiteRequest), array('page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite)), object(Response))
     (vendor/sonata-project/page-bundle/src/Page/PageServiceManager.php:83)
  at Sonata\PageBundle\Page\PageServiceManager->execute(object(SnapshotPageProxy), object(SiteRequest), array('page' => object(SnapshotPageProxy), 'site' => object(SonataPageSite)), object(Response))
     (vendor/symfony/http-kernel/HttpKernel.php:159)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(SiteRequest), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:81)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(SiteRequest), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:201)
  at Symfony\Component\HttpKernel\Kernel->handle(object(SiteRequest))
     (public/index.php:26) 

@jordisala1991
Copy link
Member

Did you try with kernel.debug false?

AFAIK there is some logic on SonataBlockBundle to avoid exceptions when kernel.debug is false.

@eerison
Copy link
Contributor Author

eerison commented Sep 12, 2022

Did you try with kernel.debug false?

AFAIK there is some logic on SonataBlockBundle to avoid exceptions when kernel.debug is false.

I can try this, But I remember to took this issue in production once!

@eerison
Copy link
Contributor Author

eerison commented Sep 12, 2022

Hey @jordisala1991 you are right, the page doesn't crash with debug=false

But any block is rendered, I have a simple text block and it doesn't appear into the page :/

Screenshot 2022-09-12 at 12 17 22

I guess it should skip only blocks that doesn't exist!

Screenshot 2022-09-12 at 12 19 20

@jordisala1991
Copy link
Member

Indeed, there is something wrong then.

@eerison
Copy link
Contributor Author

eerison commented Sep 12, 2022

and ... does it an impediment for release 4.0 👀 ?

@jordisala1991
Copy link
Member

Does it depend on the order? Maybe if you place first the block that works and later the one that does not work?

@eerison
Copy link
Contributor Author

eerison commented Sep 12, 2022

other question, should it be handled in sonata block or here?

@eerison
Copy link
Contributor Author

eerison commented Sep 12, 2022

Does it depend on the order? Maybe if you place first the block that works and later the one that does not work?

The same issue, O moved simple text block to the first position and the page is still blank!

@haivala
Copy link
Contributor

haivala commented Sep 13, 2022

I have never seen this problem. What does it mean when you say the block does not exist? How did you end up in this situation?

@jordisala1991
Copy link
Member

Upgrading from3.x to 4.x will cause some blocks to be removed, so you might end up in that situation easily if you rely on default Sonata blocks

@eerison
Copy link
Contributor Author

eerison commented Sep 13, 2022

  • 1 Create a block (a custom block)
  • 2 Create a snapshot
  • 3 Rename your block class or remove
  • You will see this error in the page that uses the old block

@eerison
Copy link
Contributor Author

eerison commented Sep 13, 2022

Upgrading from3.x to 4.x will cause some blocks to be removed, so you might end up in that situation easily if you rely on default Sonata blocks

or do this 😄

@eerison
Copy link
Contributor Author

eerison commented Sep 23, 2022

Ok just to make sure, I keep this ticket open, But it's not a impediment for 4.x anymore correct @VincentLanglet @jordisala1991 ?

@VincentLanglet
Copy link
Member

Ok just to make sure, I keep this ticket open, But it's not a impediment for 4.x anymore correct @VincentLanglet @jordisala1991 ?

It will kinda solved since you'll be able to do it with the exception manager strategy

@eerison
Copy link
Contributor Author

eerison commented Sep 24, 2022

for me I still have the same issue, even if I use manager strategy

@eerison
Copy link
Contributor Author

eerison commented Sep 26, 2022

Hey @VincentLanglet

what do you mean "I recommend you dump the strategy code" sonata-project/SonataBlockBundle#1117 (comment)

Screenshot 2022-09-26 at 11 47 10
I'm testing with the block bundle 4.x, and even with debug false my page is black.

I don't know what I should change :/, could you test it create email block in 3.x and switch for 4.x again?

@VincentLanglet
Copy link
Member

what do you mean "I recommend you dump the strategy code"

I mean to debug, like I did.

I went into my vendor, used xdbug/dump() methods, and I looked where the code was executed, which method, and
dumped the strategy_manager used to see that it used the keep_all filter strategy, and the debug manager strategy.

I'm testing with the block bundle 4.x, and even with debug false my page is black.

That's exactly the behavior expected since

  • Keep_all filter keep the exception.
  • Debug manager, display nothing.

So like I already said many times, the best hypothesis so far is the fact you don't have the right configuration.
When I changed the configuration, it worked perfectly.

could you test it create email block in 3.x and switch for 4.x again?

No cause, I already passed too much time having to configure a db, create things etc.

@eerison
Copy link
Contributor Author

eerison commented Sep 26, 2022

Ok, then I'm checking the first 2 issues as solved ;)

@eerison
Copy link
Contributor Author

eerison commented Sep 27, 2022

Screen.Recording.2022-09-27.at.09.59.14.mov

I can delete the block that doesn't exist from block's edit page ❤️

But from batch and composer page it doesn't work

@eerison
Copy link
Contributor Author

eerison commented Sep 28, 2022

This batch issue will be solved in this PR: sonata-project/SonataDoctrineORMAdminBundle#1695

for composer page I would say it's not a big problem, because if some block doesn't exist, the user can remove in block list.

IMO we can check this issue as solved

@eerison eerison closed this as completed Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants