-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
fix #17191: improved consistency and readability of UrlManager::creat… #20089
base: master
Are you sure you want to change the base?
Conversation
…::createUrl() method
PR Summary
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #20089 +/- ##
==========================================
- Coverage 48.02% 48.02% -0.01%
==========================================
Files 445 445
Lines 43890 43884 -6
==========================================
- Hits 21078 21074 -4
+ Misses 22812 22810 -2 ☔ View full report in Codecov by Sentry. |
…::createAbsoluteUrl(, ) method
I'm not sure about this. After #20077 Also, new code does not seem to be equivalent to the old one, so I would like to see some explanation why it was changed. |
I was trying to fix #17191 @rob006. Reading throughout the message I came across this #17191 (comment). After fixing isRelative in #20077, I modified both createUrl and createAbsoluteUrl to make the behaviour more consistent. Why do you say that isRelative is slower now? Moreover, the code behaviour is the same as before, I would expect tests to fail otherwise. |
I'm skeptical on this. I'd expect functions natively in php to be faster. Regardless, Caution
This function may not give correct results for relative or invalid URLs, and the results may not even match common behavior of HTTP clients. If URLs from untrusted input need to be parsed, extra validation is required, e.g. by using [filter_var()](https://www.php.net/manual/en/function.filter-var.php) with the FILTER_VALIDATE_URL filter. |
@ggh2e3 can you give some example of inconsistencies in the old code? |
@ggh2e3 @SamMousa Also, I have very little faith in tests in this case. It really looks like tests cover only basic scenarios and I'm sure there are edge cases not covered by tests. |
@SamMousa when I fixed isRelative, I wrote some tests. The only one failing with the old implementation was the one reported in #17191. You'll find the use case here: @rob006 if you provide some examples (or tell me where I can find some) I may improve the test coverage |
I don't see changes to the Base URL class in this PR though.. am I missing something? (Sorry on mobile so not ideal for browsing gh) |
@ggh2e3 I don't have any particular case in mind, but for example you PR removed |
Hi, in order to improve readability and make the behaviour more consistent, I have changed the implementation of both createUrl and CreateAbsoluteUrl methods. They're now based on Url::isRelative method. I think there are (already) enough tests to cover those cases.
Thank you :)