Skip to content

Commit

Permalink
bug #36239 [HttpKernel][LoggerDataCollector] Prevent keys collisions …
Browse files Browse the repository at this point in the history
…in the sanitized logs processing (fancyweb)

This PR was merged into the 3.4 branch.

Discussion
----------

[HttpKernel][LoggerDataCollector] Prevent keys collisions in the sanitized logs processing

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #36159
| License       | MIT
| Doc PR        | -

`$sanitizedLogs` is used with numeric and "associative" keys. To prevent collisions when the message is a number, we can simply prepend all messages with a random letter (so we avoid a behavior refactor). It doesn't matter since they key is only used for the processing, it is dropped at the end.

Commits
-------

79fe888 [HttpKernel][LoggerDataCollector] Prevent keys collisions in the sanitized logs processing
  • Loading branch information
nicolas-grekas committed Mar 31, 2020
2 parents b9c2693 + 79fe888 commit 0b27194
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Expand Up @@ -172,7 +172,7 @@ private function sanitizeLogs($logs)
continue;
}

$message = $log['message'];
$message = '_'.$log['message'];
$exception = $log['context']['exception'];

if ($exception instanceof SilencedErrorContext) {
Expand Down
Expand Up @@ -132,13 +132,15 @@ public function getCollectTestData()
[
['message' => 'foo3', 'context' => ['exception' => new \ErrorException('warning', 0, E_USER_WARNING)], 'priority' => 100, 'priorityName' => 'DEBUG'],
['message' => 'foo3', 'context' => ['exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'],
['message' => '0', 'context' => ['exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'],
],
[
['message' => 'foo3', 'context' => ['exception' => ['warning', E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG'],
['message' => 'foo3', 'context' => ['exception' => [E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true],
['message' => '0', 'context' => ['exception' => [E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true],
],
0,
1,
2,
];
}
}

0 comments on commit 0b27194

Please sign in to comment.