Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Routing] Make important parameters required when matching #29770

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

Conversation

vudaltsov
Copy link
Contributor

@vudaltsov vudaltsov commented Jan 4, 2019

Q A
Branch? master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #29763
License MIT
Doc PR n/a
  1. This PR improves "important" route parameters implementation. Instead of considering !slug to be a variable name (which is not correct from my POV and leads to a lot of '!' === $varName[0] and substr($varName, 1) snippets), I took advantage of the $token array and used offset [5] for keeping boolean importance flag. This approach improved and simplified code.
  2. This PR makes important parameters required when matching according to Matching for ! prefixed placeholders should make them required #29763

@nicolas-grekas nicolas-grekas added this to the next milestone Jan 4, 2019
@vudaltsov
Copy link
Contributor Author

As discussed with @nicolas-grekas , #29763 will be implemented in this PR as well :)

@vudaltsov vudaltsov changed the title [Routing] Refactor important route parameters [Routing] Make important parameters required when matching Jan 4, 2019
@vudaltsov vudaltsov force-pushed the routing-important-parameter-refactoring branch from 7ae21c9 to 098ab7b Compare January 4, 2019 18:38
@@ -199,7 +197,7 @@ private static function compilePattern(Route $route, $pattern, $isHost)
if (!$isHost) {
for ($i = \count($tokens) - 1; $i >= 0; --$i) {
$token = $tokens[$i];
if ('variable' === $token[0] && $route->hasDefault($token[3])) {
if ('variable' === $token[0] && !$token[5] && $route->hasDefault($token[3])) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the change that prevents matching

@vudaltsov
Copy link
Contributor Author

@nicolas-grekas , ready!

@vudaltsov
Copy link
Contributor Author

CI fails are not relevant (I see some Intl component errors), Routing is green locally :)

@vudaltsov vudaltsov force-pushed the routing-important-parameter-refactoring branch 3 times, most recently from f18a6e1 to ca35103 Compare January 15, 2019 12:36
@vudaltsov
Copy link
Contributor Author

Finally green and ready!

@vudaltsov vudaltsov force-pushed the routing-important-parameter-refactoring branch 2 times, most recently from 4bd3fc8 to 8d4be10 Compare January 24, 2019 14:50
@vudaltsov vudaltsov force-pushed the routing-important-parameter-refactoring branch from 8d4be10 to 2c3ab22 Compare January 25, 2019 07:56
@vudaltsov
Copy link
Contributor Author

@nicolas-grekas , I managed to keep consistency with old tests!

@nicolas-grekas
Copy link
Member

Thank you @vudaltsov.

@nicolas-grekas nicolas-grekas merged commit 2c3ab22 into symfony:master Jan 25, 2019
nicolas-grekas added a commit that referenced this pull request Jan 25, 2019
… (vudaltsov)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[Routing] Make important parameters required when matching

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29763
| License       | MIT
| Doc PR        | n/a

1. This PR improves "important" route parameters implementation. Instead of considering `!slug` to be a variable name (which is not correct from my POV and leads to a lot of `'!' === $varName[0]` and `substr($varName, 1)` snippets), I took advantage of the `$token` array and used offset `[5]` for keeping boolean importance flag. This approach improved and simplified code.
1. This PR makes important parameters required when matching according to #29763

Commits
-------

2c3ab22 Made important parameters required when matching
@vudaltsov vudaltsov deleted the routing-important-parameter-refactoring branch January 25, 2019 11:28
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.3 Apr 30, 2019
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.

4 participants