Problem/Motivation

StaticRouteDiscoveryBase::createRoute isn't fully compatible with Symfony's Route creation since it only allows an array of methods not a single method. Since the previous route discovery created Symfony's route directly from the input, that signature was the interface and changing it to only allow array's broke existing code.

Steps to reproduce

Gutenberg broke:
https://www.drupal.org/project/gutenberg/issues/3607961

Proposed resolution

Re-align core's routing discovery with Symfony's route generation. StaticRouteDiscoveryBase::createRoute() accepts string|array for both $methods and $schemes, matching Symfony's Route constructor. A kernel test covers string values for both keys in a routing.yml file.

Remaining tasks

Should Attributes align with Symfony's Route interface as well? We matched them so they are aligned now
Should the previous behavior be deprecated? Kept the behaviour for string support

User interface changes

Introduced terminology

API changes

None. Two parameter types on a protected method are widened to match Symfony and previous versions of Drupal.

Data model changes

Release notes snippet

Issue fork drupal-3608776

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

neclimdul created an issue. See original summary.

neclimdul’s picture

Title: PHP attributes for route discovery isn't fully compatible with Symfony routes » Route discovery isn't fully compatible with Symfony routes
Issue summary: View changes
Status: Active » Needs review

Its all route discovery, Attribute change was only the root cause.

I guess its an open question is Attribute discovery should also support strings. It seems like a convenient shortcut but I didn't make that change in the MR.

joelpittet’s picture

Issue tags: +Needs tests

Where the problem was introduced #3311365: Use PHP attributes for route discovery

Might need a regression test, to get this committed but otherwise it’s RTBC

godotislate’s picture

We might as well make the same change for schemes here as well, since the Route constructor takes string|array.

godotislate’s picture

Status: Needs review » Needs work
joelpittet’s picture

Title: Route discovery isn't fully compatible with Symfony routes » Regression: Route discovery isn't fully compatible with Symfony routes
joelpittet’s picture

Title: Regression: Route discovery isn't fully compatible with Symfony routes » [regression] Route discovery isn't fully compatible with Symfony routes

Following pattern with title for helping people find these in the queue

joelpittet’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs tests
godotislate’s picture

Status: Needs review » Reviewed & tested by the community

I was surprised there wasn't an existing Kernel test class for routing, but OTOH it makes sense that most tests would be browser-based. I was also wondering if there should be an explicit test case for array values for schemes: and methods:. But this is a straightforward bug to fix, and I'm not sure that's necessary.

lgtm

catch’s picture

Version: main » 11.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to main and backported to 11.x and 11.4.x ,thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • catch committed 4fc3e081 on 11.4.x
    fix: #3608776 [regression] Route discovery isn't fully compatible with...

  • catch committed 1667b0dc on 11.x
    fix: #3608776 [regression] Route discovery isn't fully compatible with...

  • catch committed d290c9a7 on main
    fix: #3608776 [regression] Route discovery isn't fully compatible with...

joelpittet’s picture

Thanks all for a quick turnaround!

My initial thought was choosing array only was the way to go, if I was choosing today but BC and parity wins for happier users