Issue #2968541 by vokidas, borisson_: ActiveLinkResponseFilter fails to set active link with query in non-alphabetical order

merge-requests/1654/head
Alex Pott 2018-05-09 08:51:54 +01:00
parent 4ed1bcf646
commit ef8a5c3de6
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
2 changed files with 16 additions and 0 deletions

View File

@ -127,6 +127,9 @@ class ActiveLinkResponseFilter implements EventSubscriberInterface {
$search_key_current_path = 'data-drupal-link-system-path="' . $current_path . '"';
$search_key_front = 'data-drupal-link-system-path="<front>"';
// Receive the query in a standardized manner.
ksort($query);
$offset = 0;
// There are two distinct conditions that can make a link be marked active:
// 1. A link has the current path in its 'data-drupal-link-system-path'

View File

@ -238,6 +238,19 @@ class ActiveLinkResponseFilterTest extends UnitTestCase {
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => ""]];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => TRUE]];
// Query with unsorted keys must match when the attribute is in sorted form.
$context = [
'path' => 'myfrontpage',
'front' => TRUE,
'language' => 'en',
'query' => ['foo' => 'bar', 'baz' => 'qux'],
];
$attributes = [
'data-drupal-link-system-path' => 'myfrontpage',
'data-drupal-link-query' => Json::encode(['baz' => 'qux', 'foo' => 'bar']),
];
$situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes];
// Loop over the surrounding HTML variations.
$data = [];
for ($h = 0; $h < count($html); $h++) {