Problem/Motivation
If a webform block is added in Layout Builder on a node and the webform is then deleted, attempting to go to the node layout page (/node/####/layout) results in a WSOD.
The website encountered an unexpected error. Please try again later.
AssertionError: Cannot load the "webform" entity with NULL ID. in assert() (line 249 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).
assert(, 'Cannot load the "webform" entity with NULL ID.') (Line: 249)
Drupal\Core\Entity\EntityStorageBase->load(NULL) (Line: 544)
Drupal\Core\Entity\EntityBase::load(NULL) (Line: 39)
Drupal\webform\Element\Webform::preRenderWebformElement(Array)
call_user_func_array(Array, Array) (Line: 100)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. Support for this callback implementation is deprecated in 8.8.0 and will be removed in Drupal 9.0.0. See https://www.drupal.org/node/2966725', 'silenced_deprecation', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 781)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 372)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 115)
__TwigTemplate_5e51db46561e8b19434699ad6a55b392af046c3bdd4b5cc1196085dfcc53edb5->block_content(Array, Array) (Line: 216)
Twig\Template->displayBlock('content', Array, Array) (Line: 102)
__TwigTemplate_5e51db46561e8b19434699ad6a55b392af046c3bdd4b5cc1196085dfcc53edb5->doDisplay(Array, Array) (Line: 455)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 422)
Twig\Template->display(Array) (Line: 434)
Twig\Template->render(Array) (Line: 64)
twig_render_template('REDACTED_TWIG_TEMPLATE_NAME', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('block', Array) (Line: 431)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 444)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 67)
__TwigTemplate_a3f566e8a2b34fc302e96ffb93915ae88c7e08b9e7b659b6e60cc9dca17edcd9->doDisplay(Array, Array) (Line: 455)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 422)
Twig\Template->display(Array) (Line: 434)
Twig\Template->render(Array) (Line: 64)
twig_render_template('REDACTED_TWIG_TEMPLATE_NAME', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('sidebar_first', Array) (Line: 431)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 444)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 444)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 444)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 444)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
- Enable layout builder for a content type like basic page with per-node overrides allowed.
- Create a webform or use an existing one.
- Within layout builder for a specific node, add the webform as a block.
- Delete the webform.
-
- Go back to the specific node layout page. i.e. /node/####/layout
-
- A WSOD with the above error message should show.
-
Proposed resolution
Allow the layout builder page to still be accessible. If the deleted webform block needs to be deleted manually for technical reasons, perhaps display the standard "Broken Block" placeholder so this is communicated?
Remaining tasks
N/A
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Comments
Comment #2
jrockowitz commentedPlease review the attached patch.
Comment #3
pcate commentedThanks for the lightening fast patch! Patch applied cleanly to 8.x-5.22 and fixed the error. I was able to access the node layout page and remove the broken block.
Comment #4
pcate commentedComment #5
jrockowitz commentedComment #8
jrockowitz commentedComment #10
liam morlandCommit ce4e3fdba6 adds this:
$container->set('current_route_match', $request_stack);current_route_matchshould be classCurrentRouteMatchnotRequestStack. A fix is in the current merge request for #3565161: Fix issues raised by phpstan.