TypeError: Argument 1 passed to Drupal\Core\Cache\CacheableMetadata::createFromRenderArray() must be of the type array, null given

Created on 27 October 2021, over 2 years ago
Updated 26 May 2024, about 1 month ago

Problem/Motivation

I've upgraded this site from 8.9 to 9.2.7, and pages using ShareThis breaks with this error:

TypeError: Argument 1 passed to Drupal\Core\Cache\CacheableMetadata::createFromRenderArray() must be of the type array, null given, called in /var/www/docroot/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php on line 115 in Drupal\Core\Cache\CacheableMetadata::createFromRenderArray() (line 149 of core/lib/Drupal/Core/Cache/CacheableMetadata.php).
Drupal\Core\Cache\CacheableMetadata::createFromRenderArray(NULL) (Line: 115)
Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray->onBuildRender(Object, 'section_component.build.render_array', Object)
call_user_func(Array, Object, 'section_component.build.render_array', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'section_component.build.render_array') (Line: 90)
Drupal\layout_builder\SectionComponent->toRenderArray(Array, ) (Line: 86)
Drupal\layout_builder\Section->toRenderArray(Array) (Line: 317)
Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildSections(Object) (Line: 276)
Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildMultiple(Array) (Line: 340)
Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'full') (Line: 24)
Drupal\node\NodeViewBuilder->buildComponents(Array, Array, Array, 'full') (Line: 282)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 239)
Drupal\Core\Entity\EntityViewBuilder->build(Array)
call_user_func_array(Array, Array) (Line: 101)
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. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 786)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 377)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 241)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 578)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
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: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 67)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->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: 91)
Drupal\shield\ShieldMiddleware->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: 717)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

Upgrade a D8 site to D9.2.7

I'm investigating if I can isolate where in ShareThis source to improve to avoid the error. Any hint is appreciated.
I will post a .patch here if I locate it.

πŸ› Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡·Brazil afeijo Porto Alegre

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΊAustralia VladimirAus Brisbane, Australia

    Seems like layout builder issue.
    Anyone have traceable error messages? πŸ€”

  • Status changed to Needs work about 1 month ago
  • πŸ‡©πŸ‡ͺGermany diqidoq Berlin | Hamburg | New York | London | Paris

    PPmnmi should be set with more clarification on the questions maintainers have. Backtrace is provided by OT. What leads you to the assumption that this is a Layout Builder issue? Otherwise, If you are sure about this please move the issue to Layout Builder so that core LB maintainers can take a look at it.

    But consider the following: Apart from that issue here I think ShareThis is not 100% ready for Layout Builder yet. It confusingly shows 3 options of ShareThis to be addable as a Layout Builder section block on a node manage display layout. But one is only clickable but not addable (the widget), the other is addable as a field block but causes the error described here, which turns this manage display admin page into WSOD only able to get back by uninstalling ShareThis and the 3rd option is the default ShareThis block like provided on the Block layout pages. Which is recommended to use here on this node layout? It should be made clear which block should be used in a node manage display layout. Most would assume it should be the field block to provide the required context but this is the one breaking the form.

    Since Layout Builder is the go-to core module today to build node displays (not mine but for others is) you should also consider to raise the issue prio. But I leave it up to maintainers to decide.

Production build 0.69.0 2024