Skip to content

[Routing] Remove usage of deprecated _scheme requirement #9585

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 0 commits into from
Nov 24, 2013
Merged

[Routing] Remove usage of deprecated _scheme requirement #9585

merged 0 commits into from
Nov 24, 2013

Conversation

danez
Copy link
Contributor

@danez danez commented Nov 23, 2013

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #8898, #8176
License MIT
Doc PR

I removed all usages of the deprecated _scheme requirement inside the Routing Component.
Most parts were pretty easy and after multiple refactorings I came up with the solution to have a Route::hasScheme() method and check against this method.

I also checked for performance and after trying in_array, arra_flip+isset and foreach, the last one was clearly the winner.
https://gist.github.com/Danez/7609898#file-test_performance-php

I also adjusted all tests that test '_scheme' to also check the new schemes-requirement.

@@ -145,7 +145,7 @@ public function generate($name, $parameters = array(), $referenceType = self::AB
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
* it does not match the requirement
*/
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens)
protected function doGenerate($variables, $defaults, $requiredSchemes, $tokens, $parameters, $name, $referenceType, $hostTokens)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As the only requirement checked inside doGenerate was '_scheme' I exchanged $requirements with $requiredSchemes. So the semantic of this argument changed. But as this method is protected and not a public api, I thought it may be okay. Do you think this is a BC? Otherwise the only solution would be adding an additional optional parameter.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is a bc break and cannot be merged as this in 2.3.
The method is called by several other libraries that reuse the routing component.

Copy link
Member

Choose a reason for hiding this comment

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

We cannot make such a BC break in 2.3, but not even in master.

@danez
Copy link
Contributor Author

danez commented Nov 23, 2013

Okay I removed the BC on the doGenerate-method and added the schemes-requirement as new optional argument. In this case if this method would be called as before this PR it would still do the same.

@@ -141,10 +141,15 @@ public function testScheme()
{
$route = new Route('/');
$this->assertEquals(array(), $route->getSchemes(), 'schemes is initialized with array()');
$this->assertEquals(false, $route->hasScheme('http'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use: assertTrue() & assertFalse().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@fabpot fabpot merged commit dfc54f9 into symfony:2.3 Nov 24, 2013
@danez
Copy link
Contributor Author

danez commented Nov 24, 2013

By accident I completely destroyed the commit in my fork, and it seems nothing was merged. I now had to restore the commit from the reflog and gonna open a new PR.

fabpot added a commit that referenced this pull request Dec 16, 2013
…anez)

This PR was merged into the 2.3 branch.

Discussion
----------

[Routing] Remove usage of deprecated _scheme requirement

**This is exact the same commit as it was in #9585, which was not merged due to my fault. Sorry for the noise.**

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8898, #8176
| License       | MIT
| Doc PR        |

I removed all usages of the deprecated _scheme requirement inside the Routing Component.
Most parts were pretty easy and after multiple refactorings I came up with the solution to have a Route::hasScheme() method and check against this method.

I also checked for performance and after trying in_array, arra_flip+isset and foreach, the last one was clearly the winner.
https://gist.github.com/Danez/7609898#file-test_performance-php

I also adjusted all tests that test '_scheme' to also check the new schemes-requirement.

Commits
-------

557dfaa Remove usage of deprecated _scheme in Routing Component
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.

7 participants