Skip to content

Commit 35d085d

Browse files
[FrameworkBundle] Fix warming up routes
1 parent 2852856 commit 35d085d

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

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)