Keep the query string when comparing the current address - #883
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #883 +/- ##
=========================================
Coverage 98.56% 98.57%
- Complexity 389 391 +2
=========================================
Files 24 24
Lines 909 911 +2
=========================================
+ Hits 896 898 +2
Misses 13 13 ☔ View full report in Codecov by Harness. |
|
Suites doing assertions might have legitimate use cases for both behaviors. So maybe we need to make this change opt-in instead of always preserving the query string (potentially breaking existing suites that work since years). And the name of the protected method |
|
Good point on the BC risk, done. public function __construct(Session $session, bool $compareQueryString = false)
Two shape decisions I made on my own, happy to change either:
On 522 tests green, PHPStan clean. |
Fixes #656
cleanUrl()now keeps the query string, the same way #357 taught it to keep the fragment back in 2013.Two things came out of the homework you asked for in the issue, @aik099.
Why it was implemented this way: it never was a decision. In #566 you wrote "I guess this was some kind to normalize url", @stof asked @everzet for the reason, and the answer never came. So there is no intent to preserve here.
The behaviour was locked in by the test suite. Before writing a single new test, exactly one test failed:
testAddressEqualsalready usedhttp://example.com/script.php/sub/url?param=true#webapp/navand asserted thataddressEquals('/sub/url#webapp/nav')passes. It now expects the query string. I added two tests built on the/login?return_url=/userexample from the original report, one per direction.I deliberately did not normalize the query string. You floated sorting the parameters and rebuilding with
http_build_query()in 2014, and @anton-siardziuk answered that the less is done implicitly the better; your 2022 reply agreed with "about the same fix for query string", so a literal treatment like the fragment is what this does. Say the word if you want the normalization too.The part that is your call. This changes assertion results: a suite that wrote
addressEquals('/login')while sitting on/login?x=1used to pass and will now fail.cleanUrl()isprotected, so subclasses are affected as well.CONTRIBUTING.mdsays to branch frommaster, so that is where this is, but retarget it to2-architecture-changesif you would rather not ship it in a minor.522 tests green, PHPStan clean.
CHANGES.mduntouched.