Problem/Motivation
A similar issue was already posted but the integrated fix does not work of you send HTML mails with links.
https://www.drupal.org/project/registration/issues/3346373
I think the proposed solution to use renderPlain() does not solve the issue.
In our case the following errors appears while processing the queue via cron:
[error] 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() (line 251 of /app/docroot/core/lib/Drupal/Core/Render/Renderer.php).
Steps to reproduce
Send out HTML email using the reminder mail via cron.
Proposed resolution
The correct approach to omit these kind of logic exception is to render the mail inside a render context.
Attached a patch, that does exactly this and resolves the issue.
Comments
Comment #2
ayalon commentedComment #3
john.oltman commentedThis was addressed in https://www.drupal.org/project/registration/issues/3346373Please install the latest release and see if it solves the issue. If it doesn't, that other issue should be re-opened.I am guessing, if you are using the dev branch, that it is pinned to an older release of dev. You should try rc-1 instead of dev. The error message implies the call is made "outside of renderPlain", and that other issue switched to a renderPlain, so the error message you are reporting does not jive with the patch you supplied.Sorry - I did not read your original post correctly. I am still confused by the error message. Can you confirm the release you are using? The error message implies that the module is not using renderPlain - but renderPlain is in fact being used. I am surprised that an HTML email with a link would behave differently than one without.
Re-opening this issue for now. Again, my apologies for misreading your original post.
Comment #4
john.oltman commentedComment #5
ayalon commentedI can confirm, that this error happens with the release that is using renderPlain().
I think, calling "new FormattableMarkup()" raises the issue as well and therefore I have wrapped it into a renderContext and reverted renderPlain to render.
Comment #6
john.oltman commentedThanks for confirming the release. renderPlain creates a render context and uses it for rendering, so I'll have to dig into this further to see why that would not be sufficient for what you are doing. You wouldn't happen to have a full stack trace by chance would you. I would like to be sure that the render that is failing is from the Registration module. It could be that some other module or custom code is doing early rendering without a context when creating its render array - and somehow your patch covers that up. Still a mystery at this point.
Comment #7
john.oltman commentedAlso @ayalon if possible could you post the HTML source of your reminder email here or to my D.org account contact page, so I can try and reproduce the issue in my test environment. I would like to see it fail, and then see how the patch fixes it, in my debugger.
Comment #8
john.oltman commentedComment #9
john.oltman commentedComment #10
john.oltman commentedComment #11
john.oltman commentedComment #12
john.oltman commented