diff --git a/core/lib/Drupal/Core/Form/FormSubmitter.php b/core/lib/Drupal/Core/Form/FormSubmitter.php index 42c33a9..3daaa3b 100644 --- a/core/lib/Drupal/Core/Form/FormSubmitter.php +++ b/core/lib/Drupal/Core/Form/FormSubmitter.php @@ -136,7 +136,8 @@ public function redirectForm(FormStateInterface $form_state) { } // If no redirect was specified, redirect to the current path. elseif ($redirect === NULL) { - $url = $this->requestStack->getCurrentRequest()->getUri(); + $request = $this->requestStack->getCurrentRequest(); + $url = $this->urlGenerator->generateFromRoute('', [], ['query' => $request->query->all(), 'absolute' => TRUE]); } if ($url) { diff --git a/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php b/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php index b10d41e..4e7e85c 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php @@ -107,6 +107,12 @@ public function testRedirectWithNull() { $form_state->expects($this->once()) ->method('getRedirect') ->willReturn(NULL); + + $this->urlGenerator->expects($this->once()) + ->method('generateFromRoute') + ->with('', [], ['query' => [], 'absolute' => TRUE]) + ->willReturn('http://localhost/test-path'); + $redirect = $form_submitter->redirectForm($form_state); // If we have no redirect, we redirect to the current URL. $this->assertSame('http://localhost/test-path', $redirect->getTargetUrl());