8000 [Routing] Route priority is lost when configuring hosts · Issue #58843 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Routing] Route priority is lost when configuring hosts #58843

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
BeBlood opened this issue Nov 12, 2024 · 0 comments
Closed

[Routing] Route priority is lost when configuring hosts #58843

BeBlood opened this issue Nov 12, 2024 · 0 comments

Comments

@BeBlood
Copy link
Contributor
BeBlood commented Nov 12, 2024

Symfony version(s) affected

5.4

Description

Route for controller B has priority set:

    #[Route(path:  '/b', name: 'b_method', priority: 9999)]
    public function bMethodOne(): Response

When the host in routes.yaml is commented out, the routing priority works as expected. The bin/console debug:router command outputs the following:

❯ bin/console debug:router
 ---------- -------- -------- ------ ------
  Name       Method   Scheme   Host   Path
 ---------- -------- -------- ------ ------
  b_method   ANY      ANY      ANY    /b
  a_method   ANY      ANY      ANY    /a
 ---------- -------- -------- ------ ------

However, when the host is set, the routing priority seems to be lost. The bin/console debug:router command then shows a different order:

❯ bin/console debug:router
 ---------------- -------- -------- ---------------- --------------------------
  Name             Method   Scheme   Host             Path
 ---------------- -------- -------- ---------------- --------------------------
  a_method.fr      ANY      ANY      www.domain.fr    /a
  a_method.en      ANY      ANY      www.domain.com   /a
  b_method.fr      ANY      ANY      www.domain.fr    /b
  b_method.en      ANY      ANY      www.domain.com   /b
 ---------------- -------- -------- ---------------- --------------------------

How to reproduce

https://github.com/BeBlood/symfony-routing-bug

Possible Solution

#58842

Additional Context

The bug share similarities with #52912

@BeBlood BeBlood added the Bug label Nov 12, 2024
nicolas-grekas added a commit that referenced this issue Nov 13, 2024
…uration (BeBlood)

This PR was merged into the 5.4 branch.

Discussion
----------

[Routing] Fix: lost priority when defining hosts in configuration

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | #58843
| License       | MIT

When host are configured in routing, the original route is removed from the collection and then re-added. During this process, the route's priority is lost as it's not preserved during the removal and re-addition.

Bug has similarities with #52912 (resolved for prefix)

Commits
-------

437e6ad [Routing] Fix: lost priority when defining hosts in configuration
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

3 participants
0