From adcf78885b59c4baf2821d369aafd7f7d878de89 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Fri, 6 Dec 2013 09:43:31 -0500 Subject: [PATCH] Fixes #1446: infinite loop may occur when using EmailTarget and there's missing message translation. --- framework/yii/log/EmailTarget.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/framework/yii/log/EmailTarget.php b/framework/yii/log/EmailTarget.php index b924420..f3bd98f 100644 --- a/framework/yii/log/EmailTarget.php +++ b/framework/yii/log/EmailTarget.php @@ -43,9 +43,6 @@ class EmailTarget extends Target if (empty($this->message['to'])) { throw new InvalidConfigException('The "to" option must be set for EmailTarget::message.'); } - if (empty($this->message['subject'])) { - $this->message['subject'] = Yii::t('yii', 'Application Log'); - } if (is_string($this->mail)) { $this->mail = Yii::$app->getComponent($this->mail); } @@ -59,6 +56,11 @@ class EmailTarget extends Target */ public function export() { + // moved initialization of subject here because of the following issue + // https://github.com/yiisoft/yii2/issues/1446 + if (empty($this->message['subject'])) { + $this->message['subject'] = Yii::t('yii', 'Application Log'); + } $messages = array_map([$this, 'formatMessage'], $this->messages); $body = wordwrap(implode("\n", $messages), 70); $this->composeMessage($body)->send($this->mail);