Problem/Motivation

As part of #2858482: Simplify REST routing: disallow requesting POST/PATCH in any format, make consistent we realized that we need to allow to deprecate routes.
But what means a route is deprecated?

Proposed resolution

  • When generating a URL to this route it should throw a deprecation error?
  • When accessing a URL which resolves to the deprecated route we throw the error as well?

Remaining tasks

Update the policy.

User interface changes

API changes

Data model changes

Comments

dawehner created an issue. See original summary.

cilefen’s picture

Issue summary: View changes
wim leers’s picture

Issue tags: +@deprecated
wim leers’s picture

Per #2905098-24: Change block entity form handler from 'off_canvas' to 'settings_tray', #2905098 is also affected by this. I explained the strategy that @dawehner and I developed in #2858482: Simplify REST routing: disallow requesting POST/PATCH in any format, make consistent, and why I think it also works for that issue.

wim leers’s picture

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

hchonov’s picture

In #2949167: Add the link template "add-form" to content entity types I have to rename some routes e.g. node.add should became entity.node.add_form. I am considering something like \Drupal\rest\RouteProcessor\RestResourceGetRouteProcessorBC for redirecting to the new route, but there is one thing that we cannot detect - a custom or contrib code checking for the route name. So this means that at some point we'll break something somewhere. Unfortunately I have no idea how we could deal with this beide having route aliases, but the feature request for that has been rejected in Symfony.

wim leers’s picture

but there is one thing that we cannot detect - a custom or contrib code checking for the route name

Custom/contrib code linking to the old route name will continue to work just fine.

But yes, alterations or conditional logic (such as based on the current route match), that would still break. In the case of the REST routes, it was reasonable to assume that nobody was doing either of those things. More than 7 months after the commit, zero complaints. 🙏

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

hchonov’s picture

After thinking again about this I am pretty convinced that something like \Drupal\rest\RouteProcessor\RestResourceGetRouteProcessorBC is really the way to go. I would generalize it and place it in the system module and let it find the deprecated and the new route through a route definition attribute. This is also allows us to deprecate a route without replacement in case we need to do this.

Additionally we need to ensure that \Drupal\Core\Routing\Router::doMatchCollection() finds the deprecated route, which is easy as we could add a new route attribute like new_route: foo.bar to the deprecated route. Then if we find a matching route having this attribute simply return the route foo.bar instead.

How do we deal with code checking the route name for incoming requests?

  1. Do we communicate that developers should replace $route_name == 'old_route_name' with $route_name == 'old_route_name' ||  $route_name == 'new_route_name' in order to prepare for the removal of the deprecated route?
  2. Or maybe introduce a new method for the comparison - \Drupal\Core\Routing\CurrentRouteMatch::checkRouteName($route_name), which will then first compare against the route name and then against the attribute value of new_route.

How do we deal with code checking the route name inside outbound route processors?
This is similar to the previous question, but here we don't have a route match. Maybe we need a global function for both cases, which when passed a deprecated route name will do the check properly, but will trigger a deprecated error stating that one should use the new name for the comparison. Maybe \Drupal\Core\Routing\RouteProvider::compareRouteNames($a, $b)?

----

P.S. I am just thinking out loud, so please don't judge me if that aren't any good proposals :).

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

longwave’s picture

catch’s picture