Problem/Motivation

In system_requirements, pending entity updates are output as follows:

$entity_update_issues = \Drupal::service('renderer')->render($build);

This works fine on the requirements page, where the list of requirements is being rendered. However, when calling SystemManager::listRequirements() during hook_cron, for example, this causes an Exception:

LogicException: Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call. Use renderPlain()/renderRoot() or #lazy_builder/#pre_render instead. in Drupal\Core\Render\Renderer->doRender()

Proposed resolution

From what I can see in the documentation for renderRoot and renderPlain, using renderPlain is probably the best option in this case. This seems to work fine on my installs of 8.0.5 / 8.1.0-beta1.

I'll attach a patch shortly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mirroar created an issue. See original summary.

Mirroar’s picture

Here's the suggested patch.

Mirroar’s picture

Status: Active » Needs review

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

benjy’s picture

Status: Needs review » Reviewed & tested by the community

This looks good.

  • catch committed 9a0f369 on 8.2.x
    Issue #2686931 by Mirroar: system_requirements should not call Renderer...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.2.x and cherry-picked to 8.1.x. Thanks!

  • catch committed 60ea4f1 on 8.1.x
    Issue #2686931 by Mirroar: system_requirements should not call Renderer...

Status: Fixed » Closed (fixed)

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