Renderer::render with $is_root_call is deprecated in drupal:11.2.0

Created on 21 June 2025, about 1 month ago

Problem/Motivation

Attempting to render a pdf on Drupal 11.2 throws the following error:

User notice: Drupal\Core\Render\Renderer::render with $is_root_call is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use Drupal\Core\Render\Renderer::renderRoot() instead. See https://www.drupal.org/node/3497318 โ†’ .

No PDF is generated.

Relevant change record: https://www.drupal.org/node/2511330 โ†’

Steps to reproduce

Update to Drupal 11.2 and attempt to download a PDF with an existing link.

Proposed resolution

Update Drupal\entity_print\Renderer\RenderBase to use renderRoot instead of render():

/**
   * {@inheritdoc}
   */
  public function generateHtml(array $entities, array $render, $use_default_css, $optimize_css) {
    $rendered_css = $this->assetRenderer->render($entities, $use_default_css, $optimize_css);
    $render['#entity_print_css'] = $this->renderer->executeInRenderContext(new RenderContext(), function () use (&$rendered_css) {
      return $this->renderer->render($rendered_css);
    });

    $html = (string) $this->renderer->executeInRenderContext(new RenderContext(), function () use (&$render) {
//      return $this->renderer->render($render, TRUE);  OLD LINE.
      return $this->renderer->renderRoot($render); // NEW LINE.
    });

    // Allow other modules to alter the generated HTML.
    $this->dispatcher->dispatch(new PrintHtmlAlterEvent($html, $entities), PrintEvents::POST_RENDER);

    return $html;
  }

Remaining tasks

Tag a D11.2 compatible release?

User interface changes

None

API changes

None

Data model changes

None

๐Ÿ› Bug report
Status

Active

Version

2.16

Component

Code

Created by

๐Ÿ‡ณ๐Ÿ‡ฑNetherlands neograph734 Netherlands

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024