Score:0

Database update doesn't work after update from 9.2 to 9.3

ru flag

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.

4uk4 avatar
cn flag
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().
OH MY DEAR PUFFINS avatar
ru flag
Haven't thought of that, that could very much be a possibility. Thanks for the hint.
id flag
Yes it is either an outdated contributed module or a custom module not following the API.
Score:1
ru flag

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);
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.