Problem/Motivation
The redirect module has the ability to passthrough querystrings - let's test our implementation and ensure it works for both internal and external redirects and also that the responses are cached correctly.
Doing this reveals a bug. If passthrough query strings are enabled and a redirect is set up to redirect to a URL with a query string then the method
private function makeRedirectUrl($path, $query) {
return $query && $this->configFactory->get('redirect.settings')
->get('passthrough_querystring')
? "{$path}?{$query}"
: $path;
}
can result in URLs like xww.example.com/redirect?foo=bar?foo=buz which is not correct at all. This should be doing what the redirect module does and combine the query string parameters properly.
Steps to reproduce
Create a redirect from redirect to node?foo=bar. and ensure passthrough is enabled. Make a request to the decoupled router for redirect?foo=buz and views the resolved URL is broken.
Proposed resolution
Refactor \Drupal\decoupled_router\EventSubscriber\RedirectPathTranslatorSubscriber to be more closely aligned to \Drupal\redirect\EventSubscriber\RedirectRequestSubscriber::onKernelRequestCheckRedirect and it's code
// Handle internal path.
$url = $redirect->getRedirectUrl();
if ($this->config->get('passthrough_querystring')) {
$url->setOption('query', (array) $url->getOption('query') + $request_query);
}
Remaining tasks
None
User interface changes
None
API changes
None
Data model changes
None
Issue fork decoupled_router-3543594
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
alexpottComment #4
alexpottComment #5
mglamanLooks good! Added to merge train