From 6730ddfd997b67d3f9ffa322aabd3eb380d6d8c8 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Thu, 5 Mar 2020 00:40:42 +0100 Subject: [PATCH] Remove redundant body creation in case of only a preamble is set --- src/Util/EMailer/SystemMailBuilder.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Util/EMailer/SystemMailBuilder.php b/src/Util/EMailer/SystemMailBuilder.php index 59ebb59b18..3d715906bd 100644 --- a/src/Util/EMailer/SystemMailBuilder.php +++ b/src/Util/EMailer/SystemMailBuilder.php @@ -36,11 +36,11 @@ use Psr\Log\LoggerInterface; class SystemMailBuilder extends MailBuilder { /** @var string */ - protected $subject; + protected $subject = ''; /** @var string */ - protected $preamble; + protected $preamble = ''; /** @var string */ - protected $body; + protected $body = null; /** @var string */ protected $siteAdmin; @@ -71,10 +71,6 @@ class SystemMailBuilder extends MailBuilder */ public function withMessage(string $subject, string $preamble, string $body = null) { - if (!isset($body)) { - $body = $preamble; - } - $this->subject = $subject; $this->preamble = $preamble; $this->body = $body; @@ -98,7 +94,7 @@ class SystemMailBuilder extends MailBuilder */ protected function getHtmlMessage() { - $htmlVersion = BBCode::convert($this->body); + $htmlVersion = !empty($this->body) ? BBCode::convert($this->body) : ''; // load the template for private message notifications $tpl = Renderer::getMarkupTemplate('email/system/html.tpl'); @@ -117,7 +113,7 @@ class SystemMailBuilder extends MailBuilder */ protected function getPlaintextMessage() { - $textVersion = BBCode::toPlaintext($this->body); + $textVersion = !empty($this->body) ? BBCode::toPlaintext($this->body) : ''; // load the template for private message notifications $tpl = Renderer::getMarkupTemplate('email/system/text.tpl');