Skip to content

PagePathHistory (Core) loses QueryString when redirecting #77

@flipzoom

Description

@flipzoom

Description

The PagePath History module does not check if a QueryString parameter exists and redirects it without it. Example:

Old PagePath: /dhdl/?filter=1&filter=2
New PagePath: /products/

It is redirected to /products/, but without QueryString parameters.

Suggestion for a possible fix in PagePathHistory.module

Add the following in line 289

// Checks if QueryString exists
$queryString = ($this->getQueryString()) ?: "";

// Redirect
$this->session->redirect($page->url.$queryString);

And add the following new method in line 297

/**
  * Checks if QueryString exists. If so, these are added to the current redirect.
  * 
  * @return String or Boolean
  */
public function getQueryString() {

	// Init QueryString array
	$queryParameter	= array();

	// Parse current QueryString
	parse_str($_SERVER['QUERY_STRING'], $queryParameter);

	// Remove PW system QueryParameter
	unset($queryParameter['it']);

	// Return QueryString or false
	return (count($queryParameter) >= 1) ? "?".http_build_query($queryParameter) : false;
}

Setup/Environment

  • ProcessWire version: 3.0.37
  • PHP version: 7.0.12
  • MySQL version: 5.5.53-MariaDB

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions