Problem/Motivation

Renderer::render() can throw a LogicException that says:

Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call. Use renderPlain()/renderRoot() or #lazy_builder/#pre_render instead.

But renderPlain() is deprecated since #2511308: Rename RendererInterface::renderPlain() to ::renderInIsolation().

Steps to reproduce

This exception can easily be triggered with Drush:

drush ev '$build = []; \\Drupal::service(\'renderer\')->render($build);'

Proposed resolution

The exception message should tell people to use renderInIsolation() instead.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3573953

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

prudloff created an issue. See original summary.

prudloff’s picture

Issue summary: View changes
Issue tags: +Novice
prudloff’s picture

sujal kshatri made their first commit to this issue’s fork.

sujal kshatri’s picture

Hello,
Replaced renderPlain() with renderInIsolation() in Renderer exception message

sujal kshatri’s picture

Status: Active » Needs review
sivaji_ganesh_jojodae’s picture

The merge request looks good to me. I don’t see any issues with the proposed changes.

smustgrave’s picture

Doing some cleanup this doesn't need to reference any of that. The issue linked in #3 is enough.

MR is straight forward enough nice work @sujal kshatri

  • longwave committed 5af44d4a on 11.3.x
    fix: #3573953 LogicException in Renderer::render() still mentions...

  • longwave committed 4ef94500 on 11.x
    fix: #3573953 LogicException in Renderer::render() still mentions...

  • longwave committed 5fa1ac80 on main
    fix: #3573953 LogicException in Renderer::render() still mentions...
longwave’s picture

Version: main » 11.3.x-dev
Status: Reviewed & tested by the community » Fixed

Backported down to 11.3.x as exception messages are not translatable strings. Appears to already be applied to 10.6.x? Either way not really worth any more work there.

Committed and pushed 5fa1ac80f9e to main and 4ef94500825 to 11.x and 5af44d4ad0e to 11.3.x. Thanks!

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

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

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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