Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5831979

Browse files
bug #57554 [FrameworkBundle] Fix warming up routes (nicolas-grekas)
This PR was merged into the 7.1 branch. Discussion ---------- [FrameworkBundle] Fix warming up routes | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT Follows #52962 and builds on the semantics of #57553. Commits ------- cc918e9 [FrameworkBundle] Fix warming up routes
2 parents 67563c1 + cc918e9 commit 5831979

File tree

1 file changed

+5
-7
lines changed
  • src/Symfony/Bundle/FrameworkBundle/Routing

1 file changed

+5
-7
lines changed

src/Symfony/Bundle/FrameworkBundle/Routing/Router.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function getRouteCollection(): RouteCollection
6969
$this->collection->addResource(new ContainerParametersResource($this->collectedParameters));
7070

7171
try {
72-
$containerFile = ($this->paramFetcher)('kernel.cache_dir').'/'.($this->paramFetcher)('kernel.container_class').'.php';
72+
$containerFile = ($this->paramFetcher)('kernel.build_dir').'/'.($this->paramFetcher)('kernel.container_class').'.php';
7373
if (file_exists($containerFile)) {
7474
$this->collection->addResource(new FileResource($containerFile));
7575
} else {
@@ -84,14 +84,12 @@ public function getRouteCollection(): RouteCollection
8484

8585
public function warmUp(string $cacheDir, ?string $buildDir = null): array
8686
{
87-
if (!$buildDir) {
88-
return [];
87+
if (null === $currentDir = $this->getOption('cache_dir')) {
88+
return []; // skip warmUp when router doesn't use cache
8989
}
9090

91-
$currentDir = $this->getOption('cache_dir');
92-
93-
// force cache generation in build_dir
94-
$this->setOption('cache_dir', $buildDir);
91+
// force cache generation
92+
$this->setOption('cache_dir', $buildDir ?? $cacheDir);
9593
$this->getMatcher();
9694
$this->getGenerator();
9795

0 commit comments

Comments
 (0)