Skip to content

Commit 5f9abf8

Browse files
bug #40104 [HttpKernel] [Kernel] Silence failed deprecations logs writes (fancyweb)
This PR was merged into the 4.4 branch. Discussion ---------- [HttpKernel] [Kernel] Silence failed deprecations logs writes | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - When `->buildContainer()` throws because the cache directory cannot be created, we still try to write the deprecations logs inside the cache directory. In this case, the final exception is `Warning: file_put_contents(/app/var/cache/dev/App_KernelDevDebugContainerDeprecations.log): failed to open stream: No such file or directory` instead of `Unable to create the "cache" directory (/app/var/cache/dev).`. Alternative: ```php try { // ... } catch (\RuntimeException $e) } finally { if (isset($e)) { throw $e; } // ... } ``` Commits ------- b7100b6909 [HttpKernel] [Kernel] Silence deprecations logs writes
2 parents ed97eef + cde9ee8 commit 5f9abf8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Kernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,8 @@ protected function initializeContainer()
598598
if ($collectDeprecations) {
599599
restore_error_handler();
600600

601-
file_put_contents($cacheDir.'/'.$class.'Deprecations.log', serialize(array_values($collectedLogs)));
602-
file_put_contents($cacheDir.'/'.$class.'Compiler.log', null !== $container ? implode("\n", $container->getCompiler()->getLog()) : '');
601+
@file_put_contents($cacheDir.'/'.$class.'Deprecations.log', serialize(array_values($collectedLogs)));
602+
@file_put_contents($cacheDir.'/'.$class.'Compiler.log', null !== $container ? implode("\n", $container->getCompiler()->getLog()) : '');
603603
}
604604
}
605605

0 commit comments

Comments
 (0)