Skip to content

Commit e8eeb67

Browse files
bug #36239 [HttpKernel][LoggerDataCollector] Prevent keys collisions 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 | symfony/symfony#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 ------- 79fe888072 [HttpKernel][LoggerDataCollector] Prevent keys collisions in the sanitized logs processing
2 parents 73e886d + d9df6c0 commit e8eeb67

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

DataCollector/LoggerDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private function sanitizeLogs($logs)
172172
continue;
173173
}
174174

175-
$message = $log['message'];
175+
$message = '_'.$log['message'];
176176
$exception = $log['context']['exception'];
177177

178178
if ($exception instanceof SilencedErrorContext) {

Tests/DataCollector/LoggerDataCollectorTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,15 @@ public function getCollectTestData()
132132
[
133133
['message' => 'foo3', 'context' => ['exception' => new \ErrorException('warning', 0, E_USER_WARNING)], 'priority' => 100, 'priorityName' => 'DEBUG'],
134134
['message' => 'foo3', 'context' => ['exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'],
135+
['message' => '0', 'context' => ['exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'],
135136
],
136137
[
137138
['message' => 'foo3', 'context' => ['exception' => ['warning', E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG'],
138139
['message' => 'foo3', 'context' => ['exception' => [E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true],
140+
['message' => '0', 'context' => ['exception' => [E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true],
139141
],
140142
0,
141-
1,
143+
2,
142144
];
143145
}
144146
}

0 commit comments

Comments
 (0)