Skip to content
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

Routing Priority #37089

Closed
ad3n opened this issue Jun 4, 2020 · 10 comments
Closed

Routing Priority #37089

ad3n opened this issue Jun 4, 2020 · 10 comments

Comments

@ad3n
Copy link

ad3n commented Jun 4, 2020

Symfony version(s) affected: 5.1

Description
Routing Priority doesn't support for controller with only have one method

How to reproduce

@Route("/abc/{id}")
in : XClassController::__invoke()

@Route("/abc/static-value-here", priority=7)
in: YClassController::__invoke()

@ad3n ad3n added the Bug label Jun 4, 2020
@javiereguiluz javiereguiluz added this to the 5.1 milestone Jun 4, 2020
@nicolas-grekas
Copy link
Member

What does it mean? Does it break with an error? Which one?
If not, what else?

@ad3n
Copy link
Author

ad3n commented Jun 9, 2020

@nicolas-grekas: When your controller only has one method and you setting up route priority and then you create other controller also has one method (default priority is 0)

The route priority mechanism is not work properly

@xabbuh
Copy link
Member

xabbuh commented Jun 9, 2020

What exactly does that mean? What route is matched for which request and which request did you expect to be matched instead?

@ad3n
Copy link
Author

ad3n commented Jun 9, 2020

@xabbuh : when read the blog (https://symfony.com/blog/new-in-symfony-5-1-route-annotations-priority), route priority only work when your controller have two or greater method in controller

As i mention in example, i use __invoke method per controller and set up route priority because my YController route must has higher priority than XController

But that's not work as my expectation. The XController always has higher priority so YController never execute when route match /abc/static-value-here

@xabbuh
Copy link
Member

xabbuh commented Jun 9, 2020

I can confirm this.

Status: Reviewed

@xabbuh
Copy link
Member

xabbuh commented Jun 9, 2020

Looking at the implementation I think that's expected. The priority is only taken into account for the routes that are part of the same collection (i.e. are loaded from annotations of the same class).

/cc @nicolas-grekas

@nicolas-grekas
Copy link
Member

I don't remember :) Priorities should be preserved when merging a subcollection into a bigger one. I think that's what the code in RouteCollection::addCollection() is doing(), isn't it?

@yceruto
Copy link
Member

yceruto commented Jun 9, 2020

I can confirm this too, and I found the issue, working on it...

@yceruto
Copy link
Member

yceruto commented Jun 9, 2020

It should be fixed in #37176

@ad3n
Copy link
Author

ad3n commented Jun 10, 2020

@yceruto thank you so much for your awesome work 👍

@fabpot fabpot closed this as completed Jun 10, 2020
fabpot added a commit that referenced this issue Jun 10, 2020
…x to the collection (yceruto)

This PR was merged into the 5.1 branch.

Discussion
----------

[Routing] Keeping routes priorities after add a name prefix to the collection

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #37089
| License       | MIT
| Doc PR        | -

Commits
-------

1010526 kept routes priorities after add a name prefix to the collection
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

7 participants