Browse Source

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

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
adcf78885b
  1. 8
      framework/yii/log/EmailTarget.php

8
framework/yii/log/EmailTarget.php

@ -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);

Loading…
Cancel
Save