scripts/image-fixes/34-znurl-query-order.stZnUrl>>equals:, new test
ZnUrlTest>>testEqualsWithQueryFieldsInAnotherOrderZnUrl>>equals: compares the queries of two URLs with =. The query is a
ZnMultiValueDictionary, a subclass of OrderedDictionary.
OrderedDictionary>>= of Pharo 14 compares the position of each key
(OrderedDictionaryTest>>testEqualsWhenKeyArentInTheSameOrder). In Pharo 13
the position was not a part of the comparison. So two URLs with the same
query fields in another order are equal in Pharo 13 and not equal in Pharo
14. Tests of three packages (ba-st Hyperspace, Stargate and Superluminal)
depend on the old answer, and one of them asserts it.
| Expression | Pharo 13 build 750 | Pharo 14 build 791 |
|---|---|---|
'https://example.com/pets?start=3&limit=2' asZnUrl = 'https://example.com/pets?limit=2&start=3' asZnUrl |
true | false (stock Cog and our VM) |
The repair compares the fields with no regard to their order. The two queries must have the same count of fields, and each field must have the same value. A field that is there more than one time has an Array of values. The order in that Array stays a part of the comparison, as in Pharo 13.
Another place for the repair is ZnMultiValueDictionary>>=. That changes
the equality of header collections too. The owner of Zinc must decide.
| Test | Defect in | State | Cause |
|---|---|---|---|
ZnUrlTest>>testEqualsWithQueryFieldsInAnotherOrder (new, 8 cases; each case has the answer of Pharo 13) |
image code | repaired | The equality of URLs took the order of the query fields from OrderedDictionary>>=. |
Last full sweeps of 2026-11-17: iospharo (sweep14-new14) and stock Cog with the Cog changes (sweepcogp14-new10), with all image fixes. "Before" is the state of the test before the repairs. The Stock Cog column has a value only where the record measured stock Cog: "PASS 3 of 3 (repair run)" is the check of each repair on stock Cog v12.0.6 with the fix entry; "-" is not measured separately.
| Test | Before | State | iospharo VM | Patched Cog | Stock Cog |
|---|---|---|---|---|---|
ZnUrlTest>>testEqualsWithQueryFieldsInAnotherOrder | repaired | PASS | PASS | - |
Run the tests in a Pharo 14 image (build 791). Some of these tests are new: the entries file adds them, so file in the entries file first, then run them.
"Run in a Playground of a Pharo 14 image (Do it and print each line)." ((ZnUrlTest selector: #testEqualsWithQueryFieldsInAnotherOrder) run) printString.
How to apply an entries file: file in 00-header.st and the entries file as one chunk (the iospharo script scripts/gen-image-fixes.py makes that chunk). Each entry checks for the defect first and prints FIXED, ADDED or SKIP. Download 00-header.st.
"Zinc: two URLs with the same query fields in another order are not equal in
Pharo 14 (2026-11-17).
Symptom: tests of three packages of the 200-package run compare a URL with a
text whose query fields are in another order than the code makes them
(ba-st/Hyperspace ZnUrlHyperspaceExtensionsTest>>testStartLimit, ba-st/Stargate
PetsRESTfulControllerTest>>testComplexPagination, four tests of
ba-st/Superluminal): 'Got https://pets.example.com/pets?limit=2&start=3 instead
of https://pets.example.com/pets?start=3&limit=2'. The tests pass on Pharo 13.
Cause: ZnUrl>>equals: compares the queries with 'self query = url query'. The
query is a ZnMultiValueDictionary, a subclass of OrderedDictionary, in Pharo 13
and in Pharo 14. OrderedDictionary>>= of Pharo 14 also compares the position
of each key (OrderedDictionaryTest>>testEqualsWhenKeyArentInTheSameOrder). So
the equality of two URLs changed with it, and nothing says that this was
meant: the hash of a ZnUrl does not look at the query, and Zinc has no test
for it.
Measured with the same expression
('https://example.com/pets?start=3&limit=2' asZnUrl =
'https://example.com/pets?limit=2&start=3' asZnUrl):
Pharo 13 build 750, stock Cog true
Pharo 14 build 791, stock Cog false
Pharo 14 build 791, our VM false
The repair: ZnUrl>>equals: compares the query fields with no regard to their
order, as in Pharo 13. The values of one field (a field that is there more
than one time) keep their order. The new test fails on the two VMs before the
repair."
fix value: #ZnUrl value: #equals:
value: [ :source | source includesSubstring: 'self query = url query' ]
value:
'equals: url
self scheme = url scheme ifFalse: [ ^ false ].
self host = url host ifFalse: [ ^ false ].
self portOrDefault = url portOrDefault ifFalse: [ ^ false ].
((self isSlash and: [ url isSlash ]) or: [ self segments = url segments ]) ifFalse: [ ^ false ].
(self hasQuery or: [ url hasQuery ])
ifTrue: [
"The same fields with the same values. The order of the fields is not a part of the comparison: the query is an OrderedDictionary, and OrderedDictionary>>= compares the position of each key."
(self hasQuery and: [ url hasQuery ]) ifFalse: [ ^ false ].
self query size = url query size ifFalse: [ ^ false ].
self query keysDo: [ :key |
(url query at: key ifAbsent: [ ^ false ]) = (self query at: key) ifFalse: [ ^ false ] ] ].
self fragment = url fragment ifFalse: [ ^ false ].
^ true'.
add value: #ZnUrlTest value: #testEqualsWithQueryFieldsInAnotherOrder value: 'testing'
value:
'testEqualsWithQueryFieldsInAnotherOrder
"Two URLs with the same query fields are equal, in each order of the fields."
| url |
url := ''https://example.com/pets?start=3&limit=2'' asZnUrl.
self assert: url equals: ''https://example.com/pets?limit=2&start=3'' asZnUrl.
self assert: url hash equals: ''https://example.com/pets?limit=2&start=3'' asZnUrl hash.
self assert: url equals: ''https://example.com/pets?start=3&limit=2'' asZnUrl.
self deny: url equals: ''https://example.com/pets?start=3&limit=5'' asZnUrl.
self deny: url equals: ''https://example.com/pets?start=3'' asZnUrl.
self deny: url equals: ''https://example.com/pets?start=3&limit=2&sort=name'' asZnUrl.
self deny: url equals: ''https://example.com/pets'' asZnUrl.
self deny: ''https://example.com/pets'' asZnUrl equals: url.
"A field that is there two times: its values keep their order."
self assert: ''https://example.com/pets?tag=a&tag=b&limit=2'' asZnUrl equals: ''https://example.com/pets?limit=2&tag=a&tag=b'' asZnUrl.
self deny: ''https://example.com/pets?tag=a&tag=b'' asZnUrl equals: ''https://example.com/pets?tag=b&tag=a'' asZnUrl'.
State of 2026-11-20. Made from the test records of the iospharo project (a second Pharo VM). The fixes are proposals for review.