8000 Regression in matching the earliest route · Issue #27512 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Regression in matching the earliest route #27512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pamil opened this issue Jun 6, 2018 · 5 comments
Closed

Regression in matching the earliest route #27512

pamil opened this issue Jun 6, 2018 · 5 comments

Comments

@pamil
Copy link
Contributor
pamil commented Jun 6, 2018

Symfony version(s) affected: 4.1.0

Description & how to reproduce
Having the following routing defined:

sylius_admin_product_variant_bulk_delete:
    path: /bulk-delete
    methods: [DELETE]
    defaults:
        _controller: sylius.controller.product_variant:bulkDeleteAction
        _sylius: ["sylius specific config..."]

sylius_admin_product_variant_delete:
    path: /{id}
    methods: [DELETE]
    defaults:
        _controller: sylius.controller.product_variant:deleteAction
        _sylius: ["sylius specific config..."]

After upgrading from the most recent 4.0.x to 4.1.0, the router started to match the second route for a DELETE /bulk-delete request, treating bulk-delete as {id}. As mentioned in https://symfony.com/doc/current/routing/requirements.html, the earliest route should be matched.

@pamil pamil changed the title Regression in matching the first route Regression in matching the earliest route Jun 6, 2018
@xabbuh
Copy link
Member
xabbuh commented Jun 6, 2018

Can you check if this is the same as #27491 which was fixed in #27498?

@nicolas-grekas
Copy link
Member

I tried adding this test case in UrlMatcherTest, and it passes. We'd need more info.

+    public function testStaticThenCatchAll()
+    {
+        $coll = new RouteCollection();
+        $coll->add('a', (new Route('/bulk-delete'))->setMethods('DELETE'));
+        $coll->add('b', (new Route('/{id}'))->setMethods('DELETE'));
+
+        $matcher = $this->getUrlMatcher($coll, new RequestContext('', 'DELETE', '/bulk-delete'));
+        $this->assertSame('a', $matcher->match('/bulk-delete')['_route']);
+    }

@pamil
Copy link
Contributor Author
pamil commented Jun 6, 2018

I'll try to create a Symfony project reproducing this bug, will be back in a few minutes.

@nicolas-grekas
Copy link
Member

Can you check if #27511 fixes the issue?

@pamil
Copy link
Contributor Author
pamil commented Jun 7, 2018

@nicolas-grekas it fixes the issue, thank you a lot, looking forward to v4.1.1 🎉

@fabpot fabpot closed this as completed Jun 10, 2018
fabpot added a commit that referenced this issue Jun 10, 2018
…n-capturing groups (nicolas-grekas)

This PR was merged into the 4.1 branch.

Discussion
----------

[Routing] fix matching host patterns, utf8 prefixes and non-capturing groups

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27448, #27461, #27504, #27512
| License       | MIT
| Doc PR        | -

Commits
-------

465b15c [Routing] fix matching host patterns, utf8 prefixes and non-capturing groups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
0