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

Url only outputs the last value of a query parameter

$
0
0

Problem/Motivation

Drupal uses PHP's parse_str function to parse querystrings in multiple places. This function incorrectly assumes that a parameter name can occur only once and returns just the last value.

Example with drush php:

>>> print \Drupal\Core\Url::fromUri('https://example.com/page?tag=one&tag=two')->toString();
https://example.com/page?tag=two

This behavior is a PHP-ism and is not a web standard. Other platforms may and do use the format of repeated param name to pass multiple values.

Further reading:

Proposed resolution

Implement a version of parse_str that is backwards compatible, i.e. treats ?tag=one&tag=two the same way as ?tag[0]=one&tag[1]=two.

Remaining tasks

Add a way to control the output of query arguments.

User interface changes

None

API changes

New static method Drupal\Core\Url::parseString($string).

Data model changes

None.

Release notes snippet

Fixed a bug in parsing query strings with repeated param names.


Viewing all articles
Browse latest Browse all 291829

Trending Articles



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