Commit 36538636 authored by Oleksandr Kuzava's avatar Oleksandr Kuzava Committed by Bohdan Artemchuk
Browse files

Issue #3029462 by nginex, tamarpe, bohart: Out of memory when leaving Email address field blank

parent 8f6efa7d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
 * Intercepts all outgoing emails to be rerouted to a configurable destination.
 */

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Egulias\EmailValidator\EmailParser;
use Egulias\EmailValidator\EmailLexer;
use Drupal\Component\Utility\Unicode;
@@ -153,6 +154,11 @@ function reroute_email_mail_alter(&$message) {
    // Extensive params keys cause OOM error in var_export().
    unset($message['params']);

    // Simplify subject to avoid OOM error in var_export().
    if ($message['subject'] instanceof TranslatableMarkup) {
      $message['subject'] = $message['subject']->render();
    }

    // Record a variable dump of the email in the recent log entries.
    $message_string = var_export($message, TRUE);