Problem/Motivation

As of Drupal 11.2.0, using \Drupal\Core\Render\Renderer::render() with the second argument $is_root_call is deprecated and will be removed in Drupal 12.0.0.

The current implementation in GeofieldGoogleMapViewStyle::render() calls:

$rendered = $this->renderer->render($build, TRUE);

This triggers a deprecation warning:

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.

This causes noisy logs in test output and will break functionality in Drupal 12.

Steps to reproduce

  1. Install the geofield_map module on a Drupal 11.2+ site.
  2. Create a View using the Geofield Google Map view style.
  3. Trigger a render of the View display (e.g. by visiting the page or running automated tests).
  4. Observe PHP deprecation notices for the use of Renderer::render() with the $is_root_call parameter.

Proposed resolution

Replace the deprecated call to Renderer::render() with Renderer::renderRoot() when rendering the $build array.

Suggested code change:

- $rendered = $this->renderer->render($build, TRUE);
+ $rendered = $this->renderer->renderRoot($build);

This eliminates the deprecation and aligns with the forward-compatible API.

Remaining tasks

  1. Create an issue.
  2. Attach patch or merge request.
  3. Get maintainer review.
  4. Commit patch.

User interface changes

None.

API changes

Replaces deprecated call to Renderer::render() with Renderer::renderRoot(). No change to public API.

Data model changes

None.

Comments

thefancywizard created an issue. See original summary.

thefancywizard’s picture

StatusFileSize
new941 bytes
danrod’s picture

Status: Active » Needs review
thefancywizard’s picture

StatusFileSize
new948 bytes

  • itamair committed cd09b11e on 11.0.x
    [#3542667] fix: Drupal\Core\Render\Renderer::render with $is_root_call...
itamair’s picture

Status: Needs review » Fixed

thanks @thefancywizard, nice catch ... committed into 11.0.x dev branch.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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