mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-15 22:09:48 +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'])) {
|
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
|
|||||||
*/
|
*/
|
||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user