Skip to content

Commit

Permalink
bug #31076 [HttpKernel] Fixed LoggerDataCollector crashing on empty f…
Browse files Browse the repository at this point in the history
…ile (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
-------

291c73a Catch empty deprecation.log silently (fixes #31050)
  • Loading branch information
nicolas-grekas committed Apr 11, 2019
2 parents 5f4c27f + 291c73a commit 9483779
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -126,9 +126,13 @@ private function getContainerDeprecationLogs()
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;
Expand Down

0 comments on commit 9483779

Please sign in to comment.