You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #35261 [Routing] Fix using a custom matcher & generator dumper class (fancyweb)
This PR was merged into the 4.3 branch.
Discussion
----------
[Routing] Fix using a custom matcher & generator dumper class
| Q | A
| ------------- | ---
| Branch? | 4.3
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
This PR fixes a BC break I encountered while upgrading an existing project from 4.2 to 4.4. In this project I use a custom `generator_dumper_class` that is not a `CompiledUrlGeneratorDumper` (it didn't exist yet). I faced 2 problems:
- The generator is considered "compiled" while it is not. This is because we don't check if the `generator_dumper_class` is effectively a `CompiledUrlGeneratorDumper` to compute the `$compiled` variable. That result in a `\TypeError: Return value of Symfony\Component\Routing\Router::getCompiledRoutes() must be of the type array, int returned`
- My custom dumper is not used at all. This is because of #31964. I altered the condition to fall back only in one way and not the other. The original issue is still fixed (if one uses a classic `UrlGenerator` + a `CompiledUrlGeneratorDumper`, it fall backs on `PhpGeneratorDumper`). However, if one uses a `CompiledUrlGenerator` + a classic `PhpGeneratorDumper` (my case), the classic dumper is still returned. Since `$compiled` is now correctly computed, this case works fine. The Router won't try to get the compiled routes and will use the "old" way.
Commits
-------
3a840a9 [Routing] Fix using a custom matcher & generator dumper class
if (null === $this->options['cache_dir'] || null === $this->options['generator_cache_class']) {
354
354
$routes = $this->getRouteCollection();
@@ -398,8 +398,8 @@ public function addExpressionLanguageProvider(ExpressionFunctionProviderInterfac
398
398
*/
399
399
protectedfunctiongetGeneratorDumperInstance()
400
400
{
401
-
// For BC, fallback to PhpGeneratorDumper if the UrlGenerator and UrlGeneratorDumper are not consistent with each other
402
-
if (is_a($this->options['generator_class'], CompiledUrlGenerator::class, true) !==is_a($this->options['generator_dumper_class'], CompiledUrlGeneratorDumper::class, true)) {
401
+
// For BC, fallback to PhpGeneratorDumper (which is the old default value) if the old UrlGenerator is used with the new default CompiledUrlGeneratorDumper
402
+
if (!is_a($this->options['generator_class'], CompiledUrlGenerator::class, true) &&is_a($this->options['generator_dumper_class'], CompiledUrlGeneratorDumper::class, true)) {
0 commit comments