-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
[Routing] Make important parameters required when matching #29770
Conversation
As discussed with @nicolas-grekas , #29763 will be implemented in this PR as well :) |
7ae21c9
to
098ab7b
Compare
@@ -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])) { |
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.
Here is the change that prevents matching
@nicolas-grekas , ready! |
CI fails are not relevant (I see some Intl component errors), Routing is green locally :) |
f18a6e1
to
ca35103
Compare
Finally green and ready! |
4bd3fc8
to
8d4be10
Compare
8d4be10
to
2c3ab22
Compare
@nicolas-grekas , I managed to keep consistency with old tests! |
Thank you @vudaltsov. |
… (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
!slug
to be a variable name (which is not correct from my POV and leads to a lot of'!' === $varName[0]
andsubstr($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.!
prefixed placeholders should make them required #29763