bug #31076 [HttpKernel] Fixed LoggerDataCollector crashing on empty file (althaus)
This PR was submitted for the 4.2 branch but it was merged into the 3.4 branch instead (closes #31076).
Discussion
----------
[HttpKernel] Fixed LoggerDataCollector crashing on empty file
| Q | A
| ------------- | ---
| Branch? | 4.2
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #31050
| License | MIT
This PR adds a check to the LoggerDataCollector if there's acutal some content in the log file.
Commits
-------
291c73a290
Catch empty deprecation.log silently (fixes #31050)
This commit is contained in:
commit
9483779f5f
|
@ -126,9 +126,13 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
|||
return [];
|
||||
}
|
||||
|
||||
if ('' === $logContent = trim(file_get_contents($file))) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$bootTime = filemtime($file);
|
||||
$logs = [];
|
||||
foreach (unserialize(file_get_contents($file)) as $log) {
|
||||
foreach (unserialize($logContent) as $log) {
|
||||
$log['context'] = ['exception' => new SilencedErrorContext($log['type'], $log['file'], $log['line'], $log['trace'], $log['count'])];
|
||||
$log['timestamp'] = $bootTime;
|
||||
$log['priority'] = 100;
|
||||
|
|
Reference in New Issue