From 8a47afef5892bed657f2672c2fcdaac90507b579 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Thu, 11 Dec 2014 13:04:25 +0000 Subject: [PATCH] Do not die if "user_history" mail template cannot be loaded --- .../Mibew/Controller/Chat/MailController.php | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/mibew/libs/classes/Mibew/Controller/Chat/MailController.php b/src/mibew/libs/classes/Mibew/Controller/Chat/MailController.php index bfb12e6e..81a90aea 100644 --- a/src/mibew/libs/classes/Mibew/Controller/Chat/MailController.php +++ b/src/mibew/libs/classes/Mibew/Controller/Chat/MailController.php @@ -116,22 +116,25 @@ class MailController extends AbstractController // Load mail templates and substitute placeholders there. $mail_template = MailTemplate::loadByName('user_history', get_current_locale()); - if (!$mail_template) { - throw new \RuntimeException('Cannot load "user_history" mail template'); + if ($mail_template) { + $this->sendMail(MailUtils::buildMessage( + $email, + MIBEW_MAILBOX, + $mail_template->buildSubject(), + $mail_template->buildBody(array( + $thread->userName, + $history, + Settings::get('title'), + Settings::get('hosturl'), + )) + )); + } else { + trigger_error( + 'Cannot send e-mail because "user_history" mail template cannot be loaded.', + E_USER_WARNING + ); } - $this->sendMail(MailUtils::buildMessage( - $email, - MIBEW_MAILBOX, - $mail_template->buildSubject(), - $mail_template->buildBody(array( - $thread->userName, - $history, - Settings::get('title'), - Settings::get('hosturl'), - )) - )); - $page = setup_logo($group); $page['email'] = $email;