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

{_locale} parameter in routing not working with Symfony >= 4.4.8 #37602

Closed
vincentjdc opened this issue Jul 17, 2020 · 3 comments
Closed

{_locale} parameter in routing not working with Symfony >= 4.4.8 #37602

vincentjdc opened this issue Jul 17, 2020 · 3 comments

Comments

@vincentjdc
Copy link

Hi,

I've a weird issue when using Symfony 4.4.8 or above.

A route defined with {_locale} parameter leads to a 404 route not found error.

I have the following routes defined

/**
 * @Route("/sites/{id}",
 *    name="site_get",
 *    methods={"GET"},
 *    requirements={"id": "\d+"},
 * )
 *
 * @Route("/{_locale}/sites/{id}",
 *    name="site_get_with_locale",
 *    methods={"GET"},
 *    requirements={"id": "\d+", "_locale": "fr|en"},
 * )
 *
 */

With Symfony 4.4.8

When calling /en/sites/1 I get a 404 error "route not found".
The debug:router show the defined routes :

site_get.0                                      GET         ANY      ANY    /api/sites/{id}                                                 
site_get_with_locale.0                          GET         ANY      ANY    /api/{_locale}/sites/{id} 

But the profiler gives a different routing configuration :
image

With Symfony 4.4.7

When calling /en/sites/1 everything is fine, I get the desired resource
The debug:router show the defined routes :

site_get.0                                      GET         ANY      ANY    /api/sites/{id}                                                 
site_get_with_locale.0                          GET         ANY      ANY    /api/{_locale}/sites/{id} 

And the profiler routing section :
image

I also wrote a post on stackoverflow :
https://stackoverflow.com/questions/62934810/symfony-4-setting-locale-parameter-in-route-definition-leads-to-no-route-f

@YaFou
Copy link
Contributor

YaFou commented Jul 17, 2020

I think this issue comes from this change: #36500 (this is the only change on the router component between the release 4.4.7 and 4.4.8).

@fancyweb
Copy link
Contributor

Status: works for me

I could not reproduce the issue. Can you provide a minimal project that reproduces it please? I think there is something else in play here because your route names end up suffixed with .0.

@xabbuh
Copy link
Member

xabbuh commented Aug 5, 2020

I am going to close here for now due to the lack of feedback. Please let us know when you have more information and we can consider to reopen.

@xabbuh xabbuh closed this as completed Aug 5, 2020
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