Updated: Comment 0

Problem/Motivation

There are usecases in Drupal which require to get routes for an actual pattern like /block/{custom_block} not for a congrete path.
This works fine until you have a regular expression in the route requirements.

Proposed resolution

Regular expressions in the route requirements are a totally valid feature, though the route provider validates the regular expression.
Maybe we could just skip it.

Remaining tasks

User interface changes

API changes

#1964922: When building a route, store the regexp

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin’s picture

This seems to be clearly a bug, since the doxygen for getRoutesByPattern() in the interface says that it expects them to have placeholders.

dawehner’s picture

Status: Active » Needs review
FileSize
2.69 KB
1.95 KB

Let's see whether this passes everything.

pwolanin’s picture

FileSize
1018 bytes

Here's a possible fix.

pwolanin’s picture

Oh, cross - posted. But I think the current code is totally wrong - it should not call getRoutesByPath($path) at all.

pwolanin’s picture

FileSize
2.23 KB

so, then we should make the path one public also.

pwolanin’s picture

As a side note - it seems the only real use case for getRoutesByPattern($pattern) is because of the re-definition of entity paths patterns in their annotation instead of using route names, so that's the *real* other bug.

There is little use case otherwise where you'd have the route pattern but not the route name or a concrete path.

Status: Needs review » Needs work

The last submitted patch, 2116111-4.patch, failed testing.

Crell’s picture

Um. I'm entirely confused as to what we're doing here. Regex route requirements are a feature of Symfony/UrlMatcher that we inherited, and are using in a few places. That's actually the primary use of requirements in the Symfony-native code. Can someone explain what the actual problem is?

pwolanin’s picture

Title: Decide whether using regex in route requirements is a good idea. » When looking up a route based on its path (pattern with slugs) we don't need to apply regex validation or other process

@Crell - updated the title.

The problem is when we have a route path pattern with slugs, it doesn't make any sense (and fails) to apply validation to the slug.

Instead we need to jsut look up that directly in the DB as the patch tries to do.

pwolanin’s picture

Title: When looking up a route based on its path (pattern with slugs) we don't need to apply regex validation or other process » When looking up a route based on its path (pattern with slugs) we don't need to apply regex validation or other processing
Status: Needs work » Needs review
FileSize
715 bytes
2.93 KB

Looks like there is one test case to be fixed. Not sure why the testbot didn't run.

Status: Needs review » Needs work

The last submitted patch, 2116111-11.patch, failed testing.

pwolanin’s picture

In IRC Crell says the preg_match($route->compile()->getRegex(), $path, $matches)) could potentially be totally removed, that's it's there as an un-benchmarked optimization(?), but I think the code still doesn't meet our needs since we effectively already know the 1 outline we want.

dawehner’s picture

I don't really get where this failure is coming from by we should extend the test coverage.

juanolalla’s picture

I don't know If I'm getting it right, but if we don't validate the regex of the slug, how can we avoid problems like this: http://symfony.com/doc/current/book/routing.html#adding-requirements ?

dawehner’s picture

Status: Needs work » Needs review
FileSize
463 bytes
6.49 KB

@juanolalla
We still validate the arguments when you have an actual request coming in.

Let's add a bit more explanation of the difference of this two methods.

dawehner’s picture

FileSize
5.04 KB

Wrong interdiff.

Status: Needs review » Needs work

The last submitted patch, route_provider-2116111-16.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
732 bytes
7.2 KB

There we go.

dawehner’s picture

Status: Needs review » Needs work

The last submitted patch, 19: route_provider-2116111-19.patch, failed testing.

dawehner’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
7.11 KB

Just a normal reroll.

Status: Needs review » Needs work

The last submitted patch, 22: provider-2116111.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
6.04 KB

Let's have a look at this rerole.

Status: Needs review » Needs work

The last submitted patch, 24: route_provider-2116111.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
846 bytes
6.52 KB

There we go.

Status: Needs review » Needs work

The last submitted patch, 26: route_provider-2116111.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
1.76 KB

That was the wrong fix.

Crell’s picture

26: route_provider-2116111.patch queued for re-testing.

The last submitted patch, 26: route_provider-2116111.patch, failed testing.

The last submitted patch, 26: route_provider-2116111.patch, failed testing.

damiankloip’s picture

+++ b/core/modules/system/lib/Drupal/system/Tests/Routing/MockRouteProvider.php
@@ -71,8 +71,29 @@ public function getRoutesByNames($names, $parameters = array()) {
+  public function getRoutesByExactPattern($pattern) {

Can we just have getRoutesByPattern and getRoutesByPath, or too vague?

Otherwise, generally looking pretty good IMO.

dawehner’s picture

FileSize
6.57 KB

Can we just have getRoutesByPattern and getRoutesByPath, or too vague?

Well, the thing you store on the route is the pattern, so we path should be the non-vague part, though people use it like it would be vague, even if it is not.

Status: Needs review » Needs work

The last submitted patch, 33: routing-2116111.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review

33: routing-2116111.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 33: routing-2116111.patch, failed testing.

kvoelker’s picture

Issue tags: +SprintWeekend2015

Going to work on this one now...

kvoelker’s picture

Status: Needs work » Needs review
FileSize
6.94 KB
6.94 KB

Re-rolled! resolved conflicts

Status: Needs review » Needs work

The last submitted patch, 38: routing-2116111-38.patch, failed testing.

ekl1773’s picture

I'm working on this for Sprint weekend!

ekl1773’s picture

Status: Needs work » Needs review
FileSize
6.9 KB

There were several conflicts.

I left the function shortcut_valid_link in the patch even though it's no longer in shortcut.module in HEAD, just to test. If testbot freaks out then that function should be removed, I think. (lines 237-260 in the module)

There is no longer a "try" in RouteProviderTest.php, so I removed that.

Just going to see what happens here...

Status: Needs review » Needs work

The last submitted patch, 41: routing-2116111-41.patch, failed testing.

Status: Needs work » Needs review

ekl1773 queued 41: routing-2116111-41.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 41: routing-2116111-41.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.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.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.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.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.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.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.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.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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.

catch’s picture

Category: Bug report » Task
Status: Needs work » Postponed (maintainer needs more info)
Issue tags: -WSCCI, -VDC, -Stalking Crell +Needs issue summary update

This looks like a micro-optimisation of a method that's only called once in core - in Drupal\views\Plugin\Derivative\ViewsLocalTask, and the patch doesn't update that one usage to the new method, so it would be dead code as far as core's concerned and there's no indication where contrib needs it. Moving to a task, but needs an issue summary update.

quietone’s picture

Issue tags: +Bug Smash Initiative

This was a bugsmash group triage issue and discussed with lendude and myself, who were unsure what to do with it. Later, catch joined and replied above. Adding tag.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Since there hasn't been followup or response to #57 going to close out for now.

If still a valid task please reopen updating issue summary.

Thanks all!