Problem/Motivation

Remark by @tim.plunkett at #2883680-72: Force all route filters and route enhancers to be non-lazy.2

+++ b/core/core.services.yml
@@ -864,10 +854,12 @@ services:
       - { name: service_collector, tag: non_lazy_route_enhancer, call: addRouteEnhancer }
+      - { name: service_collector, tag: route_enhancer, call: addRouteEnhancer  }
       - { name: service_collector, tag: non_lazy_route_filter, call: addRouteFilter }
+      - { name: service_collector, tag: route_filter, call: addRouteFilter }

Should any of these tags have @todo/@deprecated to eventually consolidate theme?

Proposed resolution

Remaining tasks

User interface changes

API changes

Deprecate the non_lazy_route_filter service tag
Deprecate the non_lazy_route_enhancer service tag

Data model changes

Comments

dawehner created an issue. See original summary.

wim leers’s picture

wim leers’s picture

Title: Combine non_lazy_route_enhancer|route_enhancer and non_lazy_route_filter|route_filter » Deprecate non_lazy_route_enhancer service tag in favor of route_enhancer, same for non_lazy_route_filter and route_filter
Issue summary: View changes
Issue tags: +BC break, +API change, +DX (Developer Experience), +maintainability

AFAICT this would be a BC breaking API change. I agree we should deprecate non_lazy_route_filter and non_lazy_route_enhancer though. That means we're back to just the Symfony concepts: route_filter and route_enhancer

wim leers’s picture

I think we should also deprecate \Drupal\Core\Routing\RouteFilterInterface and \Drupal\Core\Routing\Enhancer\RouteEnhancerInterface?

dawehner’s picture

Well yeah that is the question of this issue, how do we deprecate that. I guess we could deprecate the interface by throwing @trigger_error and also throw an error somehow in some container subscriber,

wim leers’s picture

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new3.49 KB

Maybe we could do something like this ...

Status: Needs review » Needs work

The last submitted patch, 7: 2915772-7.patch, failed testing. View results

wim leers’s picture

Looks good! 👍

+++ b/core/lib/Drupal/Core/Routing/Router.php
@@ -98,6 +98,17 @@ public function addRouteFilter(FilterInterface $route_filter) {
+    @trigger_error('non_lazy_route_filter is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, should use route_filter, see https://www.drupal.org/node/2894934', E_USER_DEPRECATED);

@@ -108,6 +119,17 @@ public function addRouteEnhancer(EnhancerInterface $route_enhancer) {
+    @trigger_error('non_lazy_route_enhancer is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, should use route_enhancer, see https://www.drupal.org/node/2894934', E_USER_DEPRECATED);

8.5.0

dawehner’s picture

@Wim Leers
Do you understand why the testbot doesn't work with this patch?

wim leers’s picture

Eh … wow. No. I've had this happen to me too. Seems like a random infra fail. Queued a new test.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new2.48 KB

@Wim Leers
I did the same earlier, so I guess something is wrong with that patch, here is the fix.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.62 KB
new2.47 KB
+++ b/core/lib/Drupal/Core/Routing/Router.php
@@ -98,6 +98,17 @@ public function addRouteFilter(FilterInterface $route_filter) {
+    @trigger_error('non_lazy_route_filter is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, should use route_filter, see https://www.drupal.org/node/2894934', E_USER_DEPRECATED);

@@ -108,6 +119,17 @@ public function addRouteEnhancer(EnhancerInterface $route_enhancer) {
+    @trigger_error('non_lazy_route_enhancer is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, should use route_enhancer, see https://www.drupal.org/node/2894934', E_USER_DEPRECATED);

Once these say 8.5.0, this is RTBC. Did that.

catch’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/lib/Drupal/Core/Routing/Router.php
@@ -98,6 +98,17 @@ public function addRouteFilter(FilterInterface $route_filter) {
 
   /**
+   * Adds a deprecated route filter.
+   *
+   * @param \Drupal\Core\Routing\FilterInterface $route_filter
+   *   The route filter.
+   */
+  public function addDeprecatedRouteFilter(FilterInterface $route_filter) {
+    @trigger_error('non_lazy_route_filter is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Instead, should use route_filter, see https://www.drupal.org/node/2894934', E_USER_DEPRECATED);
+    $this->filters[] = $route_filter;
+  }
+

I think we want to @deprecated the new methods in the docs as well here. I get a bit iffy on this when it's a bc layer rather than actual deprecated code, hence CNR rather than CNW.

dawehner’s picture

I think we want to @deprecated the new methods in the docs as well here. I get a bit iffy on this when it's a bc layer rather than actual deprecated code, hence CNR rather than CNW.

Should we mark the @internal, then they would have never been part of any public api.

xjm’s picture

So I think having a consistent way to deprecate routes and services and etc. is good. I think we could reuse the methods for any deprecated routes route filters and enhancers? And contrib could use it as well (so not necessarily internal either)?

But for that, we'd presumably need to not hardcode the message (or have a list of messages).

dawehner’s picture

I think we could reuse the methods for any deprecated routes route filters and enhancers? And contrib could use it as well (so not necessarily internal either)?

Wouldn't contrib route filters and enhancers which were tagged as "non_lazy_..." execute those deprecations as well? I'm not 100% sure what you are referring to in terms of reusing.

wim leers’s picture

#15++, for marking these @internal. Perhaps also worth adding @todo Remove in Drupal 9.0.0 for both?

Like #17, I don't understand #16.

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.

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.

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.

andypost’s picture

Related issues: +#2849595: Replace \Drupal\Core\Routing\AccessAwareRouter::__call() with the real methods
andypost’s picture

StatusFileSize
new1.96 KB
new2.75 KB

Re-roll for 9.2.x and fix for deprecation format

catch’s picture

Still not sure whether @internal vs @deprecated is best here (could probably be both too), however advantage of @deprecated is it's a signal that it's temporary code, whereas @internal is not.

So +1, also shame this got stuck for nearly four years!

Do we need a deprecation test here too?

andypost’s picture

Status: Needs review » Needs work

As we no longer expect this code useful then it needs deprecation test

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new2.2 KB
new4.95 KB

Here's a test

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.

joachim’s picture

Status: Needs review » Needs work

Looks ok but the version numbers in deprecation notices need updating.

andypost’s picture

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

I bet this does not fit in 9.5(

+++ b/core/lib/Drupal/Core/Routing/Router.php
@@ -84,6 +84,22 @@ public function addRouteFilter(FilterInterface $route_filter) {
+   * @deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Use
...
+    @trigger_error('non_lazy_route_filter is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Use route_filter instead. See https://www.drupal.org/node/2894934', E_USER_DEPRECATED);

@@ -94,6 +110,22 @@ public function addRouteEnhancer(EnhancerInterface $route_enhancer) {
+   * @deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Use
...
+    @trigger_error('non_lazy_route_enhancer is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Use route_enhancer instead. See https://www.drupal.org/node/2894934', E_USER_DEPRECATED);

+++ b/core/tests/Drupal/Tests/Core/Routing/RouterLegacyTest.php
@@ -33,4 +35,31 @@ public function testGenerateDeprecated() {
+    $this->expectDeprecation('non_lazy_route_filter is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Use route_filter instead. See https://www.drupal.org/node/2894934');
...
+    $this->expectDeprecation('non_lazy_route_enhancer is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Use route_enhancer instead. See https://www.drupal.org/node/2894934');

should be 10.1.0 and removed in 11.0.0

mrinalini9’s picture

Status: Needs work » Needs review
StatusFileSize
new4.99 KB
new7.67 KB

Rerolled patch #29 for 10.1.x by addressing #34, please review it.

mrinalini9’s picture

StatusFileSize
new4.96 KB
new3.04 KB

Fixing custom commands failure issue in #35, please review it.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Looks ready now, CR already exists

  • catch committed 8a993aec on 10.1.x
    Issue #2915772 by andypost, mrinalini9, dawehner, Wim Leers: Deprecate...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 8a993ae and pushed to 10.1.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

andypost’s picture