- Status changed to Needs review
almost 2 years ago 7:24am 21 January 2023 - Status changed to Needs work
almost 2 years ago 3:22pm 21 January 2023 - Status changed to Needs review
almost 2 years ago 11:13am 22 January 2023 - 🇫🇷France andypost
As I see the
$parameters
argument is not used and looking how$name
argument is passed I set it type to expected
string|\Symfony\Component\Routing\Route
- Status changed to Needs work
almost 2 years ago 2:37pm 23 January 2023 - 🇺🇸United States smustgrave
+ * @deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use + * the route name instead.
Think that's the last little bit and I'm good to mark it!
- Status changed to Needs review
almost 2 years ago 4:07pm 23 January 2023 - Status changed to RTBC
almost 2 years ago 9:20pm 23 January 2023 - Status changed to Needs work
almost 2 years ago 9:54pm 30 January 2023 - Status changed to Needs review
almost 2 years ago 11:53am 31 January 2023 - Status changed to RTBC
almost 2 years ago 3:04pm 31 January 2023 The last submitted patch, 26: 3151017-26.patch, failed testing. View results →
- Status changed to Needs work
almost 2 years ago 11:02am 6 February 2023 - 🇬🇧United Kingdom alexpott 🇪🇺🌍
- Nice to get this cleaned up!
-
+++ b/core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php @@ -110,16 +110,42 @@ public function generateFromRoute($name, $parameters = [], $options = [], $colle + @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Only string route names are supported. See https://www.drupal.org/node/3172303', E_USER_DEPRECATED); return $this->urlGenerator->supports($name); ... + @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use the route name instead. See https://www.drupal.org/node/3172303', E_USER_DEPRECATED); return $this->urlGenerator->getRouteDebugMessage($name, $parameters);
I always find this a bit tricky - given the urlGenerator method triggers a deprecation is adding the deprecation here necessary. Sure to the docs - but doubling up on every deprecation message can be noisy. Not sure.
-
+++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php @@ -429,17 +429,17 @@ protected function getRoute($name) { - public function getRouteDebugMessage($name, array $parameters = []) { + private function getRouteStringIdentifier($name) {
Let's add return and parameter typehinting.
-
+++ b/core/modules/help/tests/modules/help_test/src/SupernovaGenerator.php @@ -45,18 +45,4 @@ public function generateFromRoute($name, $parameters = [], $options = [], $colle - /** - * {@inheritdoc} - */ - public function supports($name) { - throw new \Exception(); - } - - /** - * {@inheritdoc} - */ - public function getRouteDebugMessage($name, array $parameters = []) { - throw new \Exception(); - }
Given this is test code I think this is fine.
- Status changed to Needs review
almost 2 years ago 1:03pm 6 February 2023 - 🇫🇷France andypost
Fix #30.2 and about 1) - I see no usage so no reason to throttle warnings
- Status changed to Needs work
almost 2 years ago 1:16pm 6 February 2023 - 🇬🇧United Kingdom alexpott 🇪🇺🌍
+++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php @@ -429,17 +429,17 @@ protected function getRoute($name) { - public function getRouteDebugMessage($name, array $parameters = []) { + private function getRouteStringIdentifier($name): string { @@ -451,4 +451,45 @@ public function getRouteDebugMessage($name, array $parameters = []) { + public function getRouteDebugMessage($name, array $parameters = []) { + @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use the route name instead. See https://www.drupal.org/node/3172303', E_USER_DEPRECATED); + return $this->getRouteStringIdentifier($name); + }
string|SymfonyRoute $name
can typehint the param too.But that also means we should leave the implementation of the old getRouteDebugMessage() alone - which is normally for the best anyway.
- Status changed to Needs review
almost 2 years ago 5:56pm 6 February 2023 - 🇫🇷France andypost
I think new private method will be removed in 📌 Only allow route names, deprecate support for route objects in UrlGenerator methods Fixed
I mean
getRouteStringIdentifier()
is a full copy ofgetRouteDebugMessage()
(which we can't type hint except doc-block as existing) so I copied code and added todo with linkupdated IS
- Status changed to RTBC
almost 2 years ago 8:08pm 6 February 2023 - Status changed to Fixed
almost 2 years ago 10:50pm 6 February 2023 - 🇬🇧United Kingdom alexpott 🇪🇺🌍
Committed 42f687a and pushed to 10.1.x. Thanks!
diff --git a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php index eec14d17f92..54d169f76ae 100644 --- a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php @@ -458,9 +458,9 @@ public function testBaseURLGeneration() { */ public function testDeprecatedMethods() { $this->expectDeprecation('Drupal\Core\Routing\UrlGenerator::getRouteDebugMessage() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use the route name instead. See https://www.drupal.org/node/3172303'); - $this->generator->getRouteDebugMessage('test'); + $this->assertSame('test', $this->generator->getRouteDebugMessage('test')); $this->expectDeprecation('Drupal\Core\Routing\UrlGenerator::supports() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Only string route names are supported. See https://www.drupal.org/node/3172303'); - $this->generator->supports('test'); + $this->assertTrue($this->generator->supports('test')); } /**
Added test coverage of the deprecated method return value.
-
alexpott →
committed d532f6fd on 10.1.x
Issue #3151017 by andypost, catch, ankithashetty, smustgrave, alexpott:...
-
alexpott →
committed d532f6fd on 10.1.x
- 🇫🇷France andypost
Thank you! The last deprecation of route objects unblocked #3151019-31: Only allow route names, deprecate support for route objects in UrlGenerator methods →
Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Fixed
about 1 year ago 9:40am 8 September 2023