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.
Comment | File | Size | Author |
---|---|---|---|
#2 | system_requirements-2686931-2.patch | 794 bytes | Mirroar |
Comments
Comment #2
Mirroar CreditAttribution: Mirroar at werk21 commentedHere's the suggested patch.
Comment #3
Mirroar CreditAttribution: Mirroar at werk21 commentedComment #5
benjy CreditAttribution: benjy at PreviousNext commentedThis looks good.
Comment #7
catchCommitted/pushed to 8.2.x and cherry-picked to 8.1.x. Thanks!