summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2018-09-13 15:37:23 (GMT)
committerNathaniel Catchpole2018-09-13 15:37:57 (GMT)
commit316b0bfcdf89132fc7ee2b64b0a85cf4e6d107e5 (patch)
treebbd06635752831fb76f856a042a305e9f33a8b6a
parenta42db5a7ee3e4594ac47f1d22804c69d3c799f3c (diff)
Issue #2986560 by kaythay, catch, mpdonadio: UnroutedUrlAssembler sorts Query params in buildExternalUrl()
(cherry picked from commit a95fa0bd7aea0a0bca15c7a47d0126fac9dbe9d9)
-rw-r--r--core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php1
-rw-r--r--core/modules/system/tests/src/Functional/Common/UrlTest.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php4
3 files changed, 3 insertions, 4 deletions
diff --git a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php
index 2569ee4..5e50f5e 100644
--- a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php
+++ b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php
@@ -78,7 +78,6 @@ class UnroutedUrlAssembler implements UnroutedUrlAssemblerInterface {
$options += ['query' => []];
$options['query'] = NestedArray::mergeDeep($parsed['query'], $options['query']);
- ksort($options['query']);
if ($parsed['fragment'] && !$options['fragment']) {
$options['fragment'] = '#' . $parsed['fragment'];
diff --git a/core/modules/system/tests/src/Functional/Common/UrlTest.php b/core/modules/system/tests/src/Functional/Common/UrlTest.php
index 8e4d7b1..362868c 100644
--- a/core/modules/system/tests/src/Functional/Common/UrlTest.php
+++ b/core/modules/system/tests/src/Functional/Common/UrlTest.php
@@ -314,7 +314,7 @@ class UrlTest extends BrowserTestBase {
$url = $test_url . '?drupal=awesome';
$query = ['awesome' => 'drupal'];
$result = Url::fromUri($url, ['query' => $query])->toString();
- $this->assertEqual('https://www.drupal.org/?awesome=drupal&drupal=awesome', $result);
+ $this->assertEqual('https://www.drupal.org/?drupal=awesome&awesome=drupal', $result);
}
}
diff --git a/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php b/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php
index 70b3880..0a46582 100644
--- a/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php
+++ b/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php
@@ -97,8 +97,8 @@ class UnroutedUrlAssemblerTest extends UnitTestCase {
['https://example.com/test', ['https' => FALSE], 'http://example.com/test'],
['https://example.com/test?foo=1#bar', [], 'https://example.com/test?foo=1#bar'],
'override-query' => ['https://example.com/test?foo=1#bar', ['query' => ['foo' => 2]], 'https://example.com/test?foo=2#bar'],
- 'override-query-merge' => ['https://example.com/test?foo=1#bar', ['query' => ['bar' => 2]], 'https://example.com/test?bar=2&foo=1#bar'],
- 'override-deep-query-merge' => ['https://example.com/test?foo=1#bar', ['query' => ['bar' => ['baz' => 'foo']]], 'https://example.com/test?bar%5Bbaz%5D=foo&foo=1#bar'],
+ 'override-query-merge' => ['https://example.com/test?foo=1#bar', ['query' => ['bar' => 2]], 'https://example.com/test?foo=1&bar=2#bar'],
+ 'override-deep-query-merge' => ['https://example.com/test?foo=1#bar', ['query' => ['bar' => ['baz' => 'foo']]], 'https://example.com/test?foo=1&bar%5Bbaz%5D=foo#bar'],
'override-fragment' => ['https://example.com/test?foo=1#bar', ['fragment' => 'baz'], 'https://example.com/test?foo=1#baz'],
['//www.drupal.org', [], '//www.drupal.org'],
];