Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 302010

Url class generates duplicate query arguments in some situations

$
0
0

Generating a URL with query string parameters that are numeric results in duplicated items in the query string.

Add the following code to a THEMENAME_preprocess_node() function:

  $query['foo'][] = 'bar';
  $query['foo'][] = 'baz';
  $url = Url::fromUri('https://google.com', ['query' => $query]);
  $variables['test'] = [
      '#type' => 'link',
      '#title' => 'foo',
    ] + $url->toRenderArray();

And the following to your theme's node.html.twig file:

Test link is {{ test }}.

The result is:

https://google.com/?foo[0]=bar&foo[1]=baz&foo[2]=bar&foo[3]=baz

Viewing all articles
Browse latest Browse all 302010

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>