8000 bug #31964 [Router] routing cache crash when using generator_class (d… · symfony/symfony@54a514f · GitHub
[go: up one dir, main page]

Skip to content

Commit 54a514f

Browse files
bug #31964 [Router] routing cache crash when using generator_class (dFayet)
This PR was merged into the 4.3 branch. Discussion ---------- [Router] routing cache crash when using generator_class | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #31807 | License | MIT Since #28865 the Router use, by default, new generator, matcher, and dumpers. This leads to crash when the Router use a custom generator, or matcher based on the old ones. Commits ------- a5b46e5 Fix routing cache broken when using generator_class
2 parents 1b835d1 + a5b46e5 commit 54a514f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Symfony/Component/Routing/Router.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
use Symfony\Component\Routing\Generator\ConfigurableRequirementsInterface;
2424
use Symfony\Component\Routing\Generator\Dumper\CompiledUrlGeneratorDumper;
2525
use Symfony\Component\Routing\Generator\Dumper\GeneratorDumperInterface;
26+
use Symfony\Component\Routing\Generator\Dumper\PhpGeneratorDumper;
2627
use Symfony\Component\Routing\Generator\UrlGenerator;
2728
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
2829
use Symfony\Component\Routing\Matcher\CompiledUrlMatcher;
2930
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherDumper;
3031
use Symfony\Component\Routing\Matcher\Dumper\MatcherDumperInterface;
32+
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
3133
use Symfony\Component\Routing\Matcher\RequestMatcherInterface;
3234
use Symfony\Component\Routing\Matcher\UrlMatcher;
3335
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
@@ -394,6 +396,11 @@ public function addExpressionLanguageProvider(ExpressionFunctionProviderInterfac
394396
*/
395397
protected function getGeneratorDumperInstance()
396398
{
399+
// For BC, fallback to PhpGeneratorDumper if the UrlGenerator and UrlGeneratorDumper are not consistent with each other
400+
if (is_a($this->options['generator_class'], CompiledUrlGenerator::class, true) !== is_a($this->options['generator_dumper_class'], CompiledUrlGeneratorDumper::class, true)) {
401+
return new PhpGeneratorDumper($this->getRouteCollection());
402+
}
403+
397404
return new $this->options['generator_dumper_class']($this->getRouteCollection());
398405
}
399406

@@ -402,6 +409,11 @@ protected function getGeneratorDumperInstance()
402409
*/< 7F74 /span>
403410
protected function getMatcherDumperInstance()
404411
{
412+
// For BC, fallback to PhpMatcherDumper if the UrlMatcher and UrlMatcherDumper are not consistent with each other
413+
if (is_a($this->options['matcher_class'], CompiledUrlMatcher::class, true) !== is_a($this->options['matcher_dumper_class'], CompiledUrlMatcherDumper::class, true)) {
414+
return new PhpMatcherDumper($this->getRouteCollection());
415+
}
416+
405417
return new $this->options['matcher_dumper_class']($this->getRouteCollection());
406418
}
407419

0 commit comments

Comments
 (0)
0