Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6a96afd

Browse files
committed
bug#47855 [Routing] TypeError in Router when using UrlGenerator (Maximilian.Beckers)
This PR was merged into the 5.4 branch.Discussion----------[Routing] TypeError in Router when using UrlGenerator| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets |Fix#47844| License | MIT| Doc PR |Fix the array_merge problem when using the `UrlGenerator ` and not the `CompiledUrlGenerator`. For more details about the bug see the issue#47844Commits-------3a20334 Fix TypeError in Router when using UrlGenerator
2 parents429bfbb +3a20334 commit6a96afd

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

‎src/Symfony/Component/Routing/Router.php‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,12 @@ public function getGenerator()
313313

314314
if (null ===$this->options['cache_dir']) {
315315
$routes =$this->getRouteCollection();
316-
$aliases = [];
317316
$compiled =is_a($this->options['generator_class'], CompiledUrlGenerator::class,true);
318317
if ($compiled) {
319318
$generatorDumper =newCompiledUrlGeneratorDumper($routes);
320-
$routes =$generatorDumper->getCompiledRoutes();
321-
$aliases =$generatorDumper->getCompiledAliases();
319+
$routes =array_merge($generatorDumper->getCompiledRoutes(),$generatorDumper->getCompiledAliases());
322320
}
323-
$this->generator =new$this->options['generator_class'](array_merge($routes,$aliases),$this->context,$this->logger,$this->defaultLocale);
321+
$this->generator =new$this->options['generator_class']($routes,$this->context,$this->logger,$this->defaultLocale);
324322
}else {
325323
$cache =$this->getConfigCacheFactory()->cache($this->options['cache_dir'].'/url_generating_routes.php',
326324
function (ConfigCacheInterface$cache) {

‎src/Symfony/Component/Routing/Tests/RouterTest.php‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
usePHPUnit\Framework\TestCase;
1515
useSymfony\Component\Config\Loader\LoaderInterface;
1616
useSymfony\Component\HttpFoundation\Request;
17+
useSymfony\Component\Routing\Generator\CompiledUrlGenerator;
1718
useSymfony\Component\Routing\Generator\UrlGenerator;
1819
useSymfony\Component\Routing\Generator\UrlGeneratorInterface;
1920
useSymfony\Component\Routing\Matcher\RequestMatcherInterface;
@@ -124,11 +125,24 @@ public function testGeneratorIsCreatedIfCacheIsNotConfigured()
124125
{
125126
$this->router->setOption('cache_dir',null);
126127

128+
$this->loader->expects($this->once())
129+
->method('load')->with('routing.yml',null)
130+
->willReturn(newRouteCollection());
131+
132+
$this->assertInstanceOf(CompiledUrlGenerator::class,$this->router->getGenerator());
133+
}
134+
135+
publicfunctiontestGeneratorIsCreatedIfCacheIsNotConfiguredNotCompiled()
136+
{
137+
$this->router->setOption('cache_dir',null);
138+
$this->router->setOption('generator_class', UrlGenerator::class);
139+
127140
$this->loader->expects($this->once())
128141
->method('load')->with('routing.yml',null)
129142
->willReturn(newRouteCollection());
130143

131144
$this->assertInstanceOf(UrlGenerator::class,$this->router->getGenerator());
145+
$this->assertNotInstanceOf(CompiledUrlGenerator::class,$this->router->getGenerator());
132146
}
133147

134148
publicfunctiontestMatchRequestWithUrlMatcherInterface()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp