0

I have unfortunately not found anything that seems to solve my issue. My Google-fu may be defunct.

I have upgraded a Drupal site from 9.2 to 9.3. This works as expected with composer (I use drupal/core-recommended). But when I proceed to update the database with drush updb, it fails with the following error:

[previous output excluded for brevity]
>  [notice] Update started: user_post_update_update_roles
>  [error]  Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call. Use renderPlain()/renderRoot() or #lazy_builder/#pre_render instead. 
>  [error]  Update failed: user_post_update_update_roles 
 [error]  Update aborted by: user_post_update_update_roles 
 [error]  Finished performing updates.

Using /update.php results in this error:

user modul
Opdatér update_roles

    Mislykket: 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. i Drupal\Core\Render\Renderer->doRender() (linje 245 af .../web/core/lib/Drupal/Core/Render/Renderer.php).

I unfortunately haven't been able to find anything that solves the issue, and since I am still fairly new to drupal, I might not know how to google it properly.

It should be noted that there are a bunch of custom modules made by my job, and the highest currently supported version is (unfortunately) 9.3.x, so upgrading to 9.4 as of writing this is a no-no (planning to upgrade the modules, of course).

I have updated the database for every patch release update without failure; this started as soon as I updated to 9.3.0 with the following command:

composer require drupal/core-recommended:9.3.0 drupal/core-composer-scaffold:9.3.0 drupal/core-project-message:9.3.0 --update-with-all-dependencies

I have updated all the patch releases in 9.2 like so:

composer update drupal/core-recommended:9.2.[insert patch release here]

All of them followed by a drush updb && drush cr.

Other possibly relevant information:

  • PHP 7.4 CLI (8.0 in Apache)
  • Apache 2.4.54
  • MariaDB 10.6.11
  • Debian 11.5
  • Drush 10.3.6

I thank you in advance. If you need more information, please do say and I will update the question.

3
  • 1
    The update hook throwing the error doesn't call render(), so my guess would be one of the custom modules implements an entity CRUD hook for the Role entity calling render().
    – 4uk4
    Commented Nov 30, 2022 at 13:19
  • Haven't thought of that, that could very much be a possibility. Thanks for the hint.
    – Angus
    Commented Nov 30, 2022 at 13:58
  • Yes it is either an outdated contributed module or a custom module not following the API.
    – mona lisa
    Commented Nov 30, 2022 at 16:10

1 Answer 1

1

As @4uk4 said, it was two of the custom modules that called render().

You may get this error if your module uses something like this in Drupal 9:

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

This can be fixed by changing it to this:

$view = \Drupal::service('renderer')->renderPlain($view);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.