Skip to content

Commit 415592a

Browse files
committed
bug symfony#43501 [HttpKernel] fix ErrorException in CacheWarmerAggregate (Ahummeling)
This PR was merged into the 4.4 branch. Discussion ---------- [HttpKernel] fix ErrorException in CacheWarmerAggregate | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | I ran into an `ErrorException` reloading after some changes. I suppose this triggered a cache warmup call. This didn't go as expected, because `$previousLogs = unserialize(file_get_contents($this->deprecationLogsFilepath));` set `$previousLogs` to `false` instead of the expected array. I think it makes sense to only call `array_merge` if `$previousLogs` was successfully instantiated as an array. My IDE also pointed out that `$collectedLogs` was possible undefined, so moving its declaration outside of the if block resolved that. Stacktrace: ``` ErrorException: Warning: array_merge(): Expected parameter 1 to be an array, bool given at /srv/vendor/symfony/http-kernel/CacheWarmer/CacheWarmerAggregate.php:106 at Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp('/srv/var/cache/local') (/srv/vendor/symfony/http-kernel/Kernel.php:584) at Symfony\Component\HttpKernel\Kernel->initializeContainer() (/srv/vendor/symfony/http-kernel/Kernel.php:786) at Symfony\Component\HttpKernel\Kernel->preBoot() (/srv/vendor/symfony/http-kernel/Kernel.php:187) at Symfony\Component\HttpKernel\Kernel->handle(object(Request)) (/srv/public/index.php:44) ``` Commits ------- 2eaa19f fix ErrorExcception in CacheWarmerAggregate
2 parents d146704 + 2eaa19f commit 415592a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ public function warmUp($cacheDir)
102102

103103
if (file_exists($this->deprecationLogsFilepath)) {
104104
$previousLogs = unserialize(file_get_contents($this->deprecationLogsFilepath));
105-
$collectedLogs = array_merge($previousLogs, $collectedLogs);
105+
if (\is_array($previousLogs)) {
106+
$collectedLogs = array_merge($previousLogs, $collectedLogs);
107+
}
106108
}
107109

108110
file_put_contents($this->deprecationLogsFilepath, serialize(array_values($collectedLogs)));

0 commit comments

Comments
 (0)