diff --git a/src/Symfony/Component/Routing/Generator/UrlGenerator.php b/src/Symfony/Component/Routing/Generator/UrlGenerator.php index 2a6328ad3f8f6..25c915c214ac1 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -262,6 +262,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa // add a query string if needed $extra = array_diff_key($parameters, $variables); + $extra = array_diff_assoc($extra, $defaults); if ($extra && $query = http_build_query($extra, '', '&')) { $url .= '?'.$query; } diff --git a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php index 0728503b0632c..363d7ffeb2e81 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php @@ -291,7 +291,7 @@ public function testQueryParamSameAsDefault() $routes = $this->getRoutes('test', new Route('/test', array('default' => 'value'))); $this->assertSame('/app.php/test?default=foo', $this->getGenerator($routes)->generate('test', array('default' => 'foo'))); - $this->assertSame('/app.php/test?default=value', $this->getGenerator($routes)->generate('test', array('default' => 'value'))); + $this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('default' => 'value'))); $this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test')); } @@ -347,6 +347,7 @@ public function testOptionalVariableWithNoRealSeparator() $generator = $this->getGenerator($routes); $this->assertSame('/app.php/get', $generator->generate('test')); + $this->assertSame('/app.php/get', $generator->generate('test'), array('what' => 'All')); $this->assertSame('/app.php/getSites', $generator->generate('test', array('what' => 'Sites'))); }