Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Routing] fix URL generation with look-around requirements#27601
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas commentedJun 14, 2018
ping@schmittjoh since you had some interest into these also. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
schmittjoh commentedJun 14, 2018
@nicolas-grekas , yeah, this is actually a pull-request from us. I've talked with Nasim, and she has suggested a slightly different fix now. Instead of turning off the validation entirely for the variable, we just remove validation of the look-around parts. This has the advantage that the value itself is still validated. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
nasimnabavi commentedJun 15, 2018
Comments are applied:
|
fabpot commentedOct 10, 2018
@nicolas-grekas@stof Ready for another review of this PR? |
stof commentedOct 10, 2018
From a performance PoV, I think it would be better to perform this regex transformation at compile time, by adding a new (optional) index in the token (if it is not there, we would use the unmodified pattern). But this would probably require doing that change in master only, considering it as a new feature (which could be fine. the original issue#10548 was tagged as an enhancement, not as a bug). |
9aa09e1 to4042e1bCompare
nicolas-grekas left a comment
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.
I just pushed some minor changes (manystrpos() are slower than a directpreg_replace() so I inlined the call). Let's merge this in 3.4: the perf impact is negligible (PCRE is fast as hell). Not worth a new token in master IMHO.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
578eb1b to1e9c795Compare1e9c795 toc474451Comparefabpot commentedFeb 21, 2019
Thank you@nasimnabavi. |
… (nasimnabavi)This PR was merged into the 3.4 branch.Discussion----------[Routing] fix URL generation with look-around requirements| Q | A| ------------- | ---| Branch? | 2.8 up to 4.1 for bug fixes| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#10548| License | MIT| Doc PR |If you have a non-catchable pattern in requirements like f.e. a positive lookahead (.+(?=/foo/)), the generator will not accept the parameter as the parameter itself cannot fulfil the requirement, but only matches in the context of the entire path.This fix looks for lookAround in the path and ignores checking the requirements if any lookAround exists.Commits-------c474451 [Routing] fix URL generation with look-around requirements
If you have a non-catchable pattern in requirements like f.e. a positive lookahead (.+(?=/foo/)), the generator will not accept the parameter as the parameter itself cannot fulfil the requirement, but only matches in the context of the entire path.
This fix looks for lookAround in the path and ignores checking the requirements if any lookAround exists.