Commit adcf7888 by Qiang Xue

Fixes #1446: infinite loop may occur when using EmailTarget and there's missing…

Fixes #1446: infinite loop may occur when using EmailTarget and there's missing message translation.
parent a0b9aedb
...@@ -43,9 +43,6 @@ class EmailTarget extends Target ...@@ -43,9 +43,6 @@ class EmailTarget extends Target
if (empty($this->message['to'])) { if (empty($this->message['to'])) {
throw new InvalidConfigException('The "to" option must be set for EmailTarget::message.'); 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)) { if (is_string($this->mail)) {
$this->mail = Yii::$app->getComponent($this->mail); $this->mail = Yii::$app->getComponent($this->mail);
} }
...@@ -59,6 +56,11 @@ class EmailTarget extends Target ...@@ -59,6 +56,11 @@ class EmailTarget extends Target
*/ */
public function export() 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); $messages = array_map([$this, 'formatMessage'], $this->messages);
$body = wordwrap(implode("\n", $messages), 70); $body = wordwrap(implode("\n", $messages), 70);
$this->composeMessage($body)->send($this->mail); $this->composeMessage($body)->send($this->mail);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment