Problem/Motivation

When renderPlain() was introduced, we forgot to update contact_mail() (and maybe other places?) to use renderPlain().

This can be a problem if the contact form is submitted while rendering, in my case, I'm displaying contact forms through an entity reference field.

Proposed resolution

Use renderPlain() instead. Using render() would be wrong, because even if the contact message rendering would add any #attached stuff, we do not want it to end up on the page itself. And we do want to process post render callbacks.

I'm not sure how exactly it should work when you want to send out HTML e-mails, because then you want the #attached stuff to be handled in a separate frame-thingy and put into the HTML mail. But that is a different problem I think.

Remaining tasks

User interface changes

API changes

Comments

berdir’s picture

Issue summary: View changes
Status: Active » Needs review

And here is a patch.

berdir’s picture

Maybe this time ;)

berdir’s picture

I'm not sure how to test this, as we would need to emulate a scenario where drupal_render_root() fails.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

Agree testing is a bridge too far here

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 2: contact-mail-render-plain-2397607-1.patch, failed testing.

berdir’s picture

Status: Needs work » Reviewed & tested by the community

Strange test fail, definitely unrelated:

Requesting https.php with a legitimate simpletest User-Agent returns OK.	Browser	SimpleTestBrowserTest.php	105	Drupal\simpletest\Tests\SimpleTestBrowserTest->testUserAgentValidation()

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes.

Committed 794a31d and pushed to 8.0.x. Thanks!

  • alexpott committed 794a31d on 8.0.x
    Issue #2397607 by Berdir: contact_mail() should use renderPlain()
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.