Skip to content

[Routing] UrlGenerator: fixed missing query param and some ignored requirements #5181

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
Aug 30, 2012

Conversation

Tobion
Copy link
Contributor

@Tobion Tobion commented Aug 5, 2012

This was pretty hard to figure out. I could fix 4 bugs and refactor the code to safe 2 variables and several assignments. Sorry for doing this in one commit, but they were highly interdependent.
See the added tests for what was fixed. The most obvious bug was that a query param was ignored if it had by accident the same name as a default param (but wasn't used in the path).
In 3 cases it generated the wrong URL that wouldn't match this route. The generator wrongly ignored either the requirements or the passed parameter. I had to adjust one test that was asserting something wrong (see comments).

@travisbot
Copy link

This pull request fails (merged 0706d18 into c99f9d2).

@Tobion
Copy link
Contributor Author

Tobion commented Aug 13, 2012

ping @fabpot

@Tobion
Copy link
Contributor Author

Tobion commented Aug 29, 2012

@fabpot I think it's important to merge this before 2.1 final.

$this->assertEquals('/app.php/testing//bar', $url);
// This must raise an exception because the default requirement for "foo" is "[^/]+" which is not met with these params.
// Generating path "/testing//bar" would be wrong as matching this route would fail.
$this->getGenerator($routes)->generate('test', array(), false);
Copy link
Member

Choose a reason for hiding this comment

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

This breaks BC.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but the test is wrong and and even if it breaks bc, it was not really useful before because it generated a URL that doesnt get matched by the route. And thats not what should happen which is why we have the requirements check on url generation in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Btw, with #5187 it would be possible to generate the URL as before (no bc break) although it doesn't really make sense in this case.

Copy link
Member

Choose a reason for hiding this comment

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

This PR has been merged ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I just wanted to draw your attention to #5187, so it gets merged too ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha, the first developer issue that is revealed by this change: see #5396

fabpot added a commit that referenced this pull request Aug 30, 2012
Commits
-------

0706d18 [Routing] fixed 4 bugs in the UrlGenerator

Discussion
----------

[Routing] UrlGenerator: fixed missing query param and some ignored requirements

This was pretty hard to figure out. I could fix 4 bugs and refactor the code to safe 2 variables and several assignments. Sorry for doing this in one commit, but they were highly interdependent.
See the added tests for what was fixed. The most obvious bug was that a query param was ignored if it had by accident the same name as a default param (but wasn't used in the path).
In 3 cases it generated the wrong URL that wouldn't match this route. The generator wrongly ignored either the requirements or the passed parameter. I had to adjust one test that was asserting something wrong (see comments).

---------------------------------------------------------------------------

by Tobion at 2012-08-13T14:22:35Z

ping @fabpot

---------------------------------------------------------------------------

by Tobion at 2012-08-29T17:53:07Z

@fabpot I think it's important to merge this before 2.1 final.
@fabpot fabpot merged commit 0706d18 into symfony:master Aug 30, 2012
fabpot added a commit that referenced this pull request Sep 5, 2012
This reverts commit 2da2a44, reversing
changes made to 5885547.
@fabpot
Copy link
Member

fabpot commented Sep 5, 2012

I've just reverted this pull request as it introduces some regressions? It was a very bad idea to merge this so close to the release of 2.1 and I'm the one to blame. Sorry about that.

@Tobion As apparently it is not possible to reopen a pull request, can you re-submit it again, so that it is not lost? Thanks and sorry again for the trouble.

@Tobion
Copy link
Contributor Author

Tobion commented Sep 5, 2012

What regressions does it introduce? I cannot reopen as i already deleted the branch locally and remote.

@Tobion
Copy link
Contributor Author

Tobion commented Sep 6, 2012

@fabpot What branch should i reopen the PR against? master or 2.1? Same questions applies to the other reverted PRs.

@fabpot
Copy link
Member

fabpot commented Sep 6, 2012

On the master branch please. Thanks.

fabpot added a commit that referenced this pull request Oct 3, 2012
This PR was merged into the master branch.

Commits
-------

e22823b [Routing] context params should have higher priority than defaults
16c1b01 [Routing] fixed 4 bugs in the UrlGenerator

Discussion
----------

[Routing] UrlGenerator: fixed missing query param and some ignored requirements

reopened version of #5181 (cherry-picked)

On top of that I fixed #5437 in my code and added test case.

---------------------------------------------------------------------------

by Tobion at 2012-10-03T18:41:45Z

@fabpot ping

---------------------------------------------------------------------------

by fabpot at 2012-10-03T18:43:43Z

IIUC, #5437 is a regression in 2.1 and should be done in 2.1, no?

---------------------------------------------------------------------------

by Tobion at 2012-10-03T18:46:42Z

It's not in 2.1 anymore as you reverted the PR.  #5437 is not valid currently and can be closed.
So this can either be merged in master or 2.1 whatever you prefer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants