Unverified Commit 4d349db9 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3126761 by puddyglum, longwave, smustgrave, acbramley: $parameters not...

Issue #3126761 by puddyglum, longwave, smustgrave, acbramley: $parameters not reassigned with array_replace in Frontpage PathProcessor
parent 758d0d54
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ public function processInbound($path, Request $request) {
      // with URL query, so that actual URL takes precedence.
      if (!empty($components['query'])) {
        parse_str($components['query'], $parameters);
        array_replace($parameters, $request->query->all());
        $parameters = array_replace($parameters, $request->query->all());
        $request->query->replace($parameters);
      }
    }
+18 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ class PathProcessorFrontTest extends UnitTestCase {
   * @legacy-covers ::processInbound
   */
  #[DataProvider('providerProcessInbound')]
  public function testProcessInbound($frontpage_path, $path, $expected, array $expected_query = []): void {
  public function testProcessInbound($frontpage_path, $path, $expected, array $expected_query = [], array $request_query = []): void {
    $config_factory = $this->prophesize(ConfigFactoryInterface::class);
    $config = $this->prophesize(ImmutableConfig::class);
    $config_factory->get('system.site')
@@ -36,6 +36,7 @@ public function testProcessInbound($frontpage_path, $path, $expected, array $exp
      ->willReturn($frontpage_path);
    $processor = new PathProcessorFront($config_factory->reveal());
    $request = new Request();
    $request->query->replace($request_query);
    $this->assertEquals($expected, $processor->processInbound($path, $request));
    $this->assertEquals($expected_query, $request->query->all());
  }
@@ -47,11 +48,26 @@ public static function providerProcessInbound() {
    return [
      'accessing frontpage' => ['/node', '/', '/node'],
      'accessing non frontpage' => ['/node', '/user', '/user'],
      'accessing frontpage with query parameters' => ['/node?example=muh',
      'accessing frontpage with query parameters' => [
        '/node?example=muh',
        '/',
        '/node',
        ['example' => 'muh'],
      ],
      'frontpage with query parameters and request query parameters' => [
        '/node?example=muh',
        '/',
        '/node',
        ['example' => 'muh', 'example2' => 'buh'],
        ['example2' => 'buh'],
      ],
      'frontpage with query parameters and replacement request query parameters' => [
        '/node?example=muh',
        '/',
        '/node',
        ['example' => 'cuh', 'example2' => 'buh'],
        ['example' => 'cuh', 'example2' => 'buh'],
      ],
    ];
  }