Fixes #16565: Added missing parts of the context message in \yii\log\Target::collect

This commit is contained in:
Alexander Kartavenko
2019-06-13 16:37:46 +03:00
committed by Alexander Makarov
parent 53e6c321d4
commit 3275f97684
3 changed files with 20 additions and 3 deletions

View File

@ -9,8 +9,9 @@ Yii Framework 2 Change Log
- Enh #17345: Improved performance of `yii\db\Connection::quoteColumnName()` (brandonkelly)
- Enh #17348: Improved performance of `yii\db\Connection::quoteTableName()` (brandonkelly)
- Enh #17353: Added `sameSite` support for `yii\web\Cookie` and `yii\web\Session::cookieParams` (rhertogh)
- Bug #17341: Allow callable objects to be set to `\yii\filters\AccessRule::$roleParams` (alexkart)
- Bug #17070: Strip invalid character from fallback file name (alexkart)
- Bug #17341: Allowed callable objects to be set to `\yii\filters\AccessRule::$roleParams` (alexkart)
- Bug #17070: Striped invalid character from fallback file name in `Content-Disposition` header when using `\yii\web\Response::sendFile` (alexkart)
- Bug #16565: Added missing parts of the context message in `\yii\log\Target::collect` (alexkart)
2.0.20 June 04, 2019

View File

@ -150,7 +150,7 @@ abstract class Target extends Component
$count = count($this->messages);
if ($count > 0 && ($final || $this->exportInterval > 0 && $count >= $this->exportInterval)) {
if (($context = $this->getContextMessage()) !== '') {
$this->messages[] = [$context, Logger::LEVEL_INFO, 'application', YII_BEGIN_TIME];
$this->messages[] = [$context, Logger::LEVEL_INFO, 'application', YII_BEGIN_TIME, [], 0];
}
// set exportInterval to 0 to avoid triggering export again while exporting
$oldExportInterval = $this->exportInterval;

View File

@ -220,6 +220,22 @@ class TargetTest extends TestCase
$formatted = $target->formatMessage([$text, $level, $category, $timestamp]);
$this->assertSame($expectedWithMicro, $formatted);
}
public function testCollectMessageStructure()
{
$target = new TestTarget(['logVars' => ['_SERVER']]);
static::$messages = [];
$messages = [
['test', 1, 'application', 1560428356.212978, [], 1888416]
];
$target->collect($messages, false);
$this->assertCount(2, static::$messages);
$this->assertCount(6, static::$messages[0]);
$this->assertCount(6, static::$messages[1]);
}
}
class TestTarget extends Target