Skip to content

Commit 9483779

Browse files
bug symfony#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 symfony#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 | symfony#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 symfony#31050)
2 parents 5f4c27f + 291c73a commit 9483779

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,13 @@ private function getContainerDeprecationLogs()
126126
return [];
127127
}
128128

129+
if ('' === $logContent = trim(file_get_contents($file))) {
130+
return [];
131+
}
132+
129133
$bootTime = filemtime($file);
130134
$logs = [];
131-
foreach (unserialize(file_get_contents($file)) as $log) {
135+
foreach (unserialize($logContent) as $log) {
132136
$log['context'] = ['exception' => new SilencedErrorContext($log['type'], $log['file'], $log['line'], $log['trace'], $log['count'])];
133137
$log['timestamp'] = $bootTime;
134138
$log['priority'] = 100;

0 commit comments

Comments
 (0)