You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the prefix 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
_preview_error ANY ANY ANY /_error/{code}.{_format}
a_method ANY ANY ANY /a
---------------- -------- -------- ------ --------------------------
However, when the prefix 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
---------------- -------- -------- ------ --------------------------
_preview_error ANY ANY ANY /_error/{code}.{_format}
a_method.cs ANY ANY ANY /a
a_method.en ANY ANY ANY /en/a
b_method.cs ANY ANY ANY /b
b_method.en ANY ANY ANY /en/b
---------------- -------- -------- ------ --------------------------
…ed prefix (pritasil)
This PR was merged into the 5.4 branch.
Discussion
----------
[Routing] Fixed priority getting lost when setting localized prefix
| Q | A
| ------------- | ---
| Branch? | 5.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | Fix#52912
| License | MIT
When a route prefix is an array, the original route is removed from the collection and then re-added with a new name and path. During this process, the route's priority is lost as it's not preserved during the removal and re-addition.
Current state of `PrefixTrait.php`
```php
$routes->remove($name);
...
$routes->add($name.'.'.$locale, $localizedRoute);
```
To resolve this issue, I implemented a change where the priority of the route is stored before removal. This stored priority is then reassigned to the route when it's added back to the collection.
Commits
-------
ba41175 [Routing] Fixed priority getting lost when defining prefix array
…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
Symfony version(s) affected
6.4.1
Description
Route for controller B has priority set:
When the prefix in
routes.yaml
is commented out, the routing priority works as expected. Thebin/console debug:router
command outputs the following:However, when the prefix is set, the routing priority seems to be lost. The
bin/console debug:router
command then shows a different order:How to reproduce
https://github.com/SystematicCZ/Symfony-Routing-bug
Possible Solution
I will try to submit PR soon
Additional Context
No response
The text was updated successfully, but these errors were encountered: