Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
in UnroutedUrlAssembler::buildExternalUrl there is the following code:
$options['query'] = NestedArray::mergeDeep($parsed['query'], $options['query']);
ksort($options['query']);
This results in the follwoing issue:
I have a link field.
Editor ist inserts a link like this: http://www.example.com&c=1&a=1&b=1
Drupal outputs is as: http://www.example.com&a=1&b=1&c=1
I noticed that because services like affiliate.net need to have query paramters at specific places.
So the questions is what is the intention to sort these parameters?
Can this removed?
Comment | File | Size | Author |
---|---|---|---|
#7 | interdiff.2986560.4-7.txt | 2.19 KB | kaythay |
#7 | 2986560-7.drupal.UnroutedUrlAssembler-sorts-Query-params-in-buildExternalUrl.patch | 2.82 KB | kaythay |
#4 | 2986560.patch | 647 bytes | catch |
Comments
Comment #2
carstenG CreditAttribution: carstenG at FFW commentedComment #3
carstenG CreditAttribution: carstenG at FFW commentedComment #4
catchWell let's find out what happens if we don't sort.
Comment #6
mpdonadio#4 shows some mostly trivial test fails b/c we used simple string assertions instead of parsing out the generated URL and comparing the parts.
https://tools.ietf.org/html/rfc3986#section-3.4 says that the query string is non-hierarchical, where in this context "hierarchical" means that order matters.
So, not sure if this is really a bug?
@carstenG, can you fix this with an outbound path processor that reorders the query parameters to what you need?
Comment #7
kaythay CreditAttribution: kaythay at Aten Design Group commentedLooks like ksort was added in this issue: #2955685: Unrouted URLs cannot have have overridden query or fragments
It is an edge case, but a significant one especially for legacy/enterprise 3rd-party links that require a certain order and/or URLs with nested URLs that also have query parameters that have not been properly encoded.
Comment #8
kaythay CreditAttribution: kaythay at Aten Design Group commentedComment #9
dawehnerI honestly can't see a reason why we should sort the query here. The merging is all what the original issue actually cared about.
Comment #10
mpdonadio#9++ I re-read the original issue and don't remember why we sorted there.
This should prevent another regression. Read the old patch a few times, and it looks like this essentially reverts a change and then simplifies a bit to read better.
Comment #11
catchI think we sort incoming query parameters to reduce the potential variations of cache keys, but it makes no sense to do so for outgoing ones.
Committed/pushed to 8.7.x and 8.6.x, thanks!
Comment #14
catch