8000 minor #40516 [HttpKernel] Add is_file() check before include (burned42) · symfony/symfony@a2d534c · GitHub
[go: up one dir, main page]

Skip to content

Commit a2d534c

Browse files
minor #40516 [HttpKernel] Add is_file() check before include (burned42)
This PR was merged into the 4.4 branch. Discussion ---------- [HttpKernel] Add is_file() check before include | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes (?) | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | I recently noticed that on every deployment I got warnings reported by sentry from the `cache:clear` command. > Warning: include(/var/www/html/var/cache/pro_/App_KernelProdContainer.php): failed to open stream: No such file or directory In `Symfony\Component\HttpKernel\Kernel` [line 469](https://github.com/symfony/symfony/blob/5.x/src/Symfony/Component/HttpKernel/Kernel.php#L469) (on 4.4 it's on [line 536](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/HttpKernel/Kernel.php#L536)) This is because the code tries to include the `$cachePath` without checking if it exists/is a file first. It seems like something similar was fixed some time ago already (#27249) some lines above. This PR fixes the mentioned warnings for me. I'm running on Symfony 5.2.5 at the moment, but the docs said that bugfixes should target branch 4.4 and new features should target 5.x, and I guess this could rather be seen as a bugfix than a new feature, so I branched off of 4.4 and also set this as target for the PR, I hope that's correct. Commits ------- 8efcc17 [HttpKernel] do is_file check before include
2 parents 0830672 + 8efcc17 commit a2d534c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Sy 8000 mfony/Component/HttpKernel/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ protected function initializeContainer()
533533
if (!flock($lock, $wouldBlock ? \LOCK_SH : \LOCK_EX)) {
534534
fclose($lock);
535535
$lock = null;
536-
} elseif (!\is_object($this->container = include $cachePath)) {
536+
} elseif (!is_file($cachePath) || !\is_object($this->container = include $cachePath)) {
537537
$this->container = null;
538538
} elseif (!$oldContainer || \get_class($this->container) !== $oldContainer->name) {
539539
flock($lock, \LOCK_UN);

0 commit comments

Comments
 (0)
0