Skip to content
Snippets Groups Projects
Commit 920eb067 authored by catch's avatar catch
Browse files

Issue #3000671 by axel.rutz, surbz, msankhala, goodboy, dawehner: Frontpage...

Issue #3000671 by axel.rutz, surbz, msankhala, goodboy, dawehner: Frontpage with query parameter results in "Page not found"
parent e2432d96
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -42,6 +42,16 @@ public function processInbound($path, Request $request) {
// might be broken so stop execution.
throw new NotFoundHttpException();
}
$components = parse_url($path);
// Remove query string and fragment.
$path = $components['path'];
// Merge query parameters from front page configuration value
// with URL query, so that actual URL takes precedence.
if (!empty($components['query'])) {
parse_str($components['query'], $parameters);
array_replace($parameters, $request->query->all());
$request->query->replace($parameters);
}
}
return $path;
}
......
......@@ -23,15 +23,17 @@ class PathProcessorFrontTest extends UnitTestCase {
* @covers ::processInbound
* @dataProvider providerProcessInbound
*/
public function testProcessInbound($path, $expected) {
public function testProcessInbound($frontpage_path, $path, $expected, array $expected_query = []) {
$config_factory = $this->prophesize(ConfigFactoryInterface::class);
$config = $this->prophesize(ImmutableConfig::class);
$config_factory->get('system.site')
->willReturn($config->reveal());
$config->get('page.front')
->willReturn('/node');
->willReturn($frontpage_path);
$processor = new PathProcessorFront($config_factory->reveal());
$this->assertEquals($expected, $processor->processInbound($path, new Request()));
$request = new Request();
$this->assertEquals($expected, $processor->processInbound($path, $request));
$this->assertEquals($expected_query, $request->query->all());
}
/**
......@@ -39,8 +41,13 @@ public function testProcessInbound($path, $expected) {
*/
public function providerProcessInbound() {
return [
['/', '/node'],
['/user', '/user'],
'accessing frontpage' => ['/node', '/', '/node'],
'accessing non frontpage' => ['/node', '/user', '/user'],
'accessing frontpage with query parameters' => ['/node?example=muh',
'/',
'/node',
['example' => 'muh'],
],
];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment