-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing] Fix route URL generation in CLI context #31023
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] Fix route URL generation in CLI context #31023
Conversation
d005c8f
to
6faae44
Compare
please do it in this PR |
src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with minor comments
src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php
Outdated
Show resolved
Hide resolved
b9e3d03
to
2cea5b6
Compare
Tests will be green once the patch is merged up to master. |
I just tested the case I described in the linked ticket, and it does behave like I wrote it so this change could technically break someone workflow. |
@fancyweb the scenario you describe would apply to the cli but not to the web, right? Having a consistent behavior looks more important to me that preserving a non-consistent one to me. Makes sense? |
It also applies to the web context but I guess it's very unlikely that someone relies on this behavior. |
2cea5b6
to
4a1ad4a
Compare
Thank you @X-Coder264. |
…264) This PR was squashed before being merged into the 4.2 branch (closes #31023). Discussion ---------- [Routing] Fix route URL generation in CLI context | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #30996 | License | MIT | Doc PR | - This fixes #30996 and makes URL generation in the CLI context behave the same as it does in the web context where the `LocaleListener` sets the default locale (to the router context). The Travis CI failure is related to the fact that the constraint for `symfony/routing` should be bumped to `^4.2.6` in the composer.json of the FrameworkBundle (when it gets tagged). Commits ------- 4a1ad4a [Routing] Fix route URL generation in CLI context
Thanks for the merge. The |
@X-Coder264 Thanks for the followup, fixed in e479b69 |
…eMC) This PR was merged into the 4.3 branch. Discussion ---------- [Routing] Fix URL generator instantiation | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT After merging my fix (PR #31023) from the 4.2 branch to 4.3 (which was master at the time) one code path which instantiates the url generator was missed. This new code path was added via #28865 and was missed during the merge because there was no merge conflict there as that code path didn't exist on 4.2. So the current state on the 4.3 branch is: - https://github.com/symfony/symfony/blob/v4.3.5/src/Symfony/Component/Routing/Router.php#L356 (default locale is properly passed to the constructor) - https://github.com/symfony/symfony/blob/v4.3.5/src/Symfony/Component/Routing/Router.php#L372 (default locale is **NOT** properly passed to the constructor) - https://github.com/symfony/symfony/blob/v4.3.5/src/Symfony/Component/Routing/Router.php#L378 (default locale is properly passed to the constructor) I noticed this in my app because tests started to fail on the branch where we are upgrading our app from SF 4.2 to 4.3 due to this. This PR fixes the inconsistency (now the default locale is passed on all three places) which fixes the bug. Commits ------- 9aa66e2 Add tests to ensure defaultLocale is properly passed to the URL generator 16c9baf Fix URL generator instantiation
This fixes #30996 and makes URL generation in the CLI context behave the same as it does in the web context where the
LocaleListener
sets the default locale (to the router context).The Travis CI failure is related to the fact that the constraint for
symfony/routing
should be bumped to^4.2.6
in the composer.json of the FrameworkBundle (when it gets tagged).