Skip to content

[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

Merged
merged 1 commit into from
Apr 22, 2019

Conversation

X-Coder264
Copy link
Contributor

@X-Coder264 X-Coder264 commented Apr 8, 2019

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).

@X-Coder264 X-Coder264 force-pushed the fix-route-url-generation-in-cli branch from d005c8f to 6faae44 Compare April 8, 2019 18:50
@nicolas-grekas nicolas-grekas added this to the 4.2 milestone Apr 8, 2019
@nicolas-grekas
Copy link
Member

the constraint for symfony/routing should be bumped to ^4.2.6 in the composer.json

please do it in this PR

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with minor comments

@X-Coder264 X-Coder264 force-pushed the fix-route-url-generation-in-cli branch 2 times, most recently from b9e3d03 to 2cea5b6 Compare April 8, 2019 21:07
@nicolas-grekas
Copy link
Member

Tests will be green once the patch is merged up to master.

@fancyweb
Copy link
Contributor

fancyweb commented Apr 9, 2019

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.

@nicolas-grekas
Copy link
Member

@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?

@fancyweb
Copy link
Contributor

It also applies to the web context but I guess it's very unlikely that someone relies on this behavior.

@fabpot fabpot force-pushed the fix-route-url-generation-in-cli branch from 2cea5b6 to 4a1ad4a Compare April 22, 2019 09:10
@fabpot
Copy link
Member

fabpot commented Apr 22, 2019

Thank you @X-Coder264.

@fabpot fabpot merged commit 4a1ad4a into symfony:4.2 Apr 22, 2019
fabpot added a commit that referenced this pull request Apr 22, 2019
…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
@X-Coder264 X-Coder264 deleted the fix-route-url-generation-in-cli branch April 22, 2019 09:20
@X-Coder264
Copy link
Contributor Author

X-Coder264 commented Apr 22, 2019

Thanks for the merge. The symfony/routing constraint for FrameworkBundle should be bumped now from ^4.2.6 to ^4.2.8 since 4.2.6 and 4.2.7 were already released since this PR was opened.

@fabpot
Copy link
Member

fabpot commented Apr 22, 2019

@X-Coder264 Thanks for the followup, fixed in e479b69

nicolas-grekas added a commit that referenced this pull request Nov 4, 2019
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants