mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-16 06:17:56 +08:00
Fixes #1446: infinite loop may occur when using EmailTarget and there's missing message translation.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user