Problem/Motivation

The PHP's parse_str function has a data-loss problem for query params with the same name (which are valid according to the URL spec). It's now being wrapped into a method in UrlHelper in #3038774: Url only outputs the last value of a query parameter.

Proposed resolution

Use UrlHelper::parseString when it's available

CommentFileSizeAuthor
#4 3052410-4.patch1.01 KBjaimeah
#2 3052410-2.patch1 KBblazey

Comments

blazey created an issue. See original summary.

blazey’s picture

Assigned: blazey » Unassigned
Status: Active » Needs review
StatusFileSize
new1 KB
dww’s picture

Status: Needs review » Postponed
Parent issue: » #3038774: Url only outputs the last value of a query parameter

Thanks for the patch! However, the upstream change still hasn't happened. Doesn't make sense to add conditional code here until the proposed function lives in *some* released version of core. ;) Calling this postponed for now.

Meanwhile, a few minor code style nits:

  1. +++ b/pathologic.module
    @@ -261,7 +262,13 @@ function _pathologic_replace($matches) {
    +      // The parse_str function overrides parameters with the same name. Use
    

    parse_str()

  2. +++ b/pathologic.module
    @@ -261,7 +262,13 @@ function _pathologic_replace($matches) {
    +      // UrlHelper::parseString when it's available.
    

    UrlHelper::parseString()

  3. +++ b/pathologic.module
    @@ -261,7 +262,13 @@ function _pathologic_replace($matches) {
    +    } else {
    

    Needs newline before else.

jaimeah’s picture

StatusFileSize
new1.01 KB

This is an excellent fix, but it fails against a different (related) patch at 2984272: Dots in query parameter names converted to underscores, so I am including a modified Patch so that it is compatible. Thank you!