diff --git a/UPGRADE-8.0.md b/UPGRADE-8.0.md index 40b4769883bad..c56e501e642fc 100644 --- a/UPGRADE-8.0.md +++ b/UPGRADE-8.0.md @@ -285,6 +285,11 @@ PropertyInfo } ``` +Routing +------- + + * Providing a non-array `_query` parameter to `UrlGenerator` causes an `InvalidParameterException` + Security -------- diff --git a/src/Symfony/Component/Routing/CHANGELOG.md b/src/Symfony/Component/Routing/CHANGELOG.md index 4ef96d53232fe..1c9b745370b22 100644 --- a/src/Symfony/Component/Routing/CHANGELOG.md +++ b/src/Symfony/Component/Routing/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +8.0 +--- + + * Providing a non-array `_query` parameter to `UrlGenerator` causes an `InvalidParameterException` + 7.4 --- diff --git a/src/Symfony/Component/Routing/Generator/UrlGenerator.php b/src/Symfony/Component/Routing/Generator/UrlGenerator.php index d82b91898194a..32d57e9c8dd5d 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -149,8 +149,7 @@ protected function doGenerate(array $variables, array $defaults, array $requirem $queryParameters = $parameters['_query']; unset($parameters['_query']); } else { - trigger_deprecation('symfony/routing', '7.4', 'Parameter "_query" is reserved for passing an array of query parameters. Passing a scalar value is deprecated and will throw an exception in Symfony 8.0.'); - // throw new InvalidParameterException('Parameter "_query" must be an array of query parameters.'); + throw new InvalidParameterException('Parameter "_query" must be an array of query parameters.'); } } diff --git a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php index 75196bd214aa2..72eb1af71d4af 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php @@ -1109,23 +1109,16 @@ public function testQueryParameterCannotSubstituteRouteParameter() ]); } - /** - * @group legacy - */ public function testQueryParametersWithScalarValue() { $routes = $this->getRoutes('user', new Route('/user/{id}')); - $this->expectUserDeprecationMessage( - 'Since symfony/routing 7.4: Parameter "_query" is reserved for passing an array of query parameters. ' . - 'Passing a scalar value is deprecated and will throw an exception in Symfony 8.0.', - ); + $this->expectException(InvalidParameterException::class); - $url = $this->getGenerator($routes)->generate('user', [ + $this->getGenerator($routes)->generate('user', [ 'id' => '123', '_query' => 'foo', ]); - $this->assertSame('/app.php/user/123?_query=foo', $url); } protected function getGenerator(RouteCollection $routes, array $parameters = [], $logger = null, ?string $defaultLocale = null)