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
- Install the geofield_map module on a Drupal 11.2+ site.
- Create a View using the Geofield Google Map view style.
- Trigger a render of the View display (e.g. by visiting the page or running automated tests).
- 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
-
Create an issue. -
Attach patch or merge request. - Get maintainer review.
- 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3542667-2-replace-deprecated-render-call.patch | 948 bytes | thefancywizard |
Comments
Comment #2
thefancywizard commentedComment #3
danrodComment #4
thefancywizard commentedComment #6
itamair commentedthanks @thefancywizard, nice catch ... committed into 11.0.x dev branch.