Issue #3408511 by nkoporec: Replace renderRoot() with renderPlain() when trying to render a notifiication in an email #3645
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The renderRoot() should be used as a response to a controller. If we use the renderRoot or render() methods incorrectly it can produce warnings such as:
LogicException: Render context is empty, because render() was called outside of a renderRoot()
We are catching a lot of this kind of logs warnings and its related to when cron processes a queue job.
Solution
Replace renderRoot with renderPlain
Issue tracker
https://www.drupal.org/project/social/issues/3408511
Theme issue tracker
[Required if applicable] Paste a link to the drupal.org theme issue queue item, either from socialbase or socialblue. If any other issue trackers were used, include links to those too.
How to test
It's hard to reproduce this one, but you can try by creating a lot of notifications for a certain user that has the frequency set to 'Immediate', then running cron multiple times to process these jobs... the warning should appear in the watchdog.
Also we need to make sure that the rendering of email notification is the same as before the change.
Definition of done
Before merge
After merge
Screenshots
Release notes
Fixed a warning about invalid render state when rendering the email notifications.
Change Record
Translations