Problem/Motivation

Fatal error on node view page after using this language formatter.

Backtrace:

Drupal\Core\Security\UntrustedCallbackException: Render #lazy_builder callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was Drupal\language_display\LanguageDisplayNodeViewBuilder::renderLinks. See https://www.drupal.org/node/2966725 in Drupal\Core\Render\Renderer->doTrustedCallback() (line 96 of core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php).
Drupal\Core\Render\Renderer->doCallback() (Line: 356)
Drupal\Core\Render\Renderer->doRender() (Line: 449)
Drupal\Core\Render\Renderer->doRender() (Line: 201)
Drupal\Core\Render\Renderer->render() (Line: 450)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 110)
__TwigTemplate_742d7889f306cd9de6faebdd9789bd8a39117b23b8986ae3c9687d279c956441->doDisplay() (Line: 405)
Twig\Template->displayWithErrorHandling() (Line: 378)
Twig\Template->display() (Line: 390)
Twig\Template->render() (Line: 65)
twig_render_template() (Line: 384)
Drupal\Core\Theme\ThemeManager->render() (Line: 436)
Drupal\Core\Render\Renderer->doRender() (Line: 201)
Drupal\Core\Render\Renderer->render() (Line: 241)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 578)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 57)
Drupal\Core\StackMiddleware\Session->handle() (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 717)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

Install drupal 9, enable module, configure to use this formatter, go to node view page.

Proposed resolution

  • Implement TrustedCallbackInterface in LanguageDisplayNodeViewBuilder.
  • Implement trustedCallbacks method and add renderLinks callback into it.

See NodeViewBuilder.php#L13

Remaining tasks

Create a fix.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Discovered while testing #3207683-14: Drupal 9 Compatibility

Comments

vlad.dancer created an issue. See original summary.

vlad.dancer’s picture

Status: Active » Needs review
StatusFileSize
new1.84 KB

Implemented TrustedCallbackInterface methods.

  • matsbla committed 264f109 on 8.x-1.x authored by vlad.dancer
    Issue #3244120 by vlad.dancer: D9, fatal error on node view page
    
matsbla’s picture

Status: Needs review » Fixed

Great, thank you!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.