8000 deprecate not passing a build dir when warming up the router cache · symfony/symfony@78470ab · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 78470ab

Browse files
committed
deprecate not passing a build dir when warming up the router cache
1 parent 37138e6 commit 78470ab

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

UPGRADE-7.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Cache
99
FrameworkBundle
1010
---------------
1111

12+
* Deprecate not passing a build dir to `RouterCacheWarmer::warmUp()` and `Router::warmUp()`
1213
* Mark classes `ConfigBuilderCacheWarmer`, `Router`, `SerializerCacheWarmer`, `TranslationsCacheWarmer`, `Translator` and `ValidatorCacheWarmer` as `final`
1314

1415
Messenger

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
7.1
55
---
66

7+
* Deprecate not passing a build dir to `RouterCacheWarmer::warmUp()` and `Router::warmUp()`
78
* Add `private_ranges` as a shortcut for private IP address ranges to the `trusted_proxies` option
89
* Mark classes `ConfigBuilderCacheWarmer`, `Router`, `SerializerCacheWarmer`, `TranslationsCacheWarmer`, `Translator` and `ValidatorCacheWarmer` as `final`
910
* Move the Router `cache_dir` to `kernel.build_dir`

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ public function __construct(ContainerInterface $container)
3636

3737
public function warmUp(string $cacheDir, string $buildDir = null): array
3838
{
39-
if (!$buildDir) {
40-
return [];
39+
if (null === $buildDir) {
40+
trigger_deprecation('symfony/framework-bundle', '7.1', sprintf('Not passing a build dir as the second argument to "%s()" is deprecated.', __METHOD__));
41+
// return [];
4142
}
4243

4344
$router = $this->container->get('router');
4445

4546
if ($router instanceof WarmableInterface) {
46-
return (array) $router->warmUp($cacheDir, $buildDir);
47+
return (array) $router->warmUp($cacheDir, $buildDir, false);
4748
}
4849

4950
throw new \LogicException(sprintf('The router "%s" cannot be warmed up because it does not implement "%s".', get_debug_type($router), WarmableInterface::class));

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,17 @@ public function getRouteCollection(): RouteCollection
8484

8585
public function warmUp(string $cacheDir, string $buildDir = null): array
8686
{
87-
if (!$buildDir) {
88-
return [];
87+
if (null === $buildDir) {
88+
if (\func_num_args() < 3) {
89+
trigger_deprecation('symfony/framework-bundle', '7.1', sprintf('Not passing a build dir as the second argument to "%s()" is deprecated.', __METHOD__));
90+
}
91+
// return [];
8992
}
9093

9194
$currentDir = $this->getOption('cache_dir');
9295

93-
// force cache generation in build_dir
94-
$this->setOption('cache_dir', $buildDir);
96+
// force cache generation (in build_dir if present)
97+
$this->setOption('cache_dir', $buildDir ?? $cacheDir);
9598 43FE
$this->getMatcher();
9699
$this->getGenerator();
97100

0 commit comments

Comments
 (0)
0