diff -u b/core/lib/Drupal/Core/EventSubscriber/CurrentPathDestinationLinkResponseFilter.php b/core/lib/Drupal/Core/EventSubscriber/CurrentPathDestinationLinkResponseFilter.php --- b/core/lib/Drupal/Core/EventSubscriber/CurrentPathDestinationLinkResponseFilter.php +++ b/core/lib/Drupal/Core/EventSubscriber/CurrentPathDestinationLinkResponseFilter.php @@ -81,11 +81,13 @@ return; } + $master_request = $this->requestStack->getMasterRequest(); + $response = $event->getResponse(); $response->setContent(static::setCurrentPathAsDestination( $response->getContent(), - ltrim($this->currentPath->getPath(), '/'), - $this->requestStack->getMasterRequest()->query->all() + ltrim($master_request->getPathInfo(), '/'), + $master_request->getQueryString() )); } @@ -99,7 +101,7 @@ * The HTML markup to update. * @param string $current_path * The system path of the currently active page. - * @param string[] $current_query + * @param string $current_query * The query string for the currently active page. * * @return string @@ -110,10 +112,10 @@ * https://www.drupal.org/comment/7938201#comment-7938201) then we can get * rid of this manual parsing and use DOMDocument instead. */ - public static function setCurrentPathAsDestination($html_markup, $current_path, array $current_query) { + public static function setCurrentPathAsDestination($html_markup, $current_path, $current_query) { $destination_value = $current_path; if (!empty($current_query)) { - $destination_value .= '?' . UrlHelper::buildQuery($current_query); + $destination_value .= '?' . $current_query; } $destination = 'destination=' . UrlHelper::encodePath($destination_value); diff -u b/core/tests/Drupal/Tests/Core/EventSubscriber/CurrentPathDestinationLinkResponseFilterTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/CurrentPathDestinationLinkResponseFilterTest.php --- b/core/tests/Drupal/Tests/Core/EventSubscriber/CurrentPathDestinationLinkResponseFilterTest.php +++ b/core/tests/Drupal/Tests/Core/EventSubscriber/CurrentPathDestinationLinkResponseFilterTest.php @@ -7,6 +7,7 @@ namespace Drupal\Tests\Core\EventSubscriber; +use Drupal\Component\Utility\UrlHelper; use Drupal\Core\EventSubscriber\CurrentPathDestinationLinkResponseFilter; use Drupal\Core\Template\Attribute; use Drupal\Tests\UnitTestCase; @@ -125,7 +126,7 @@ * @covers ::setCurrentPathAsDestination */ public function testSetCurrentPathAsDestination($html_markup, $current_path, array $current_query, $expected_html_markup) { - $this->assertSame($expected_html_markup, CurrentPathDestinationLinkResponseFilter::setCurrentPathAsDestination($html_markup, $current_path, $current_query)); + $this->assertSame($expected_html_markup, CurrentPathDestinationLinkResponseFilter::setCurrentPathAsDestination($html_markup, $current_path, UrlHelper::buildQuery($current_query))); } } only in patch2: unchanged: --- a/core/modules/user/src/Tests/UserLoginTest.php +++ b/core/modules/user/src/Tests/UserLoginTest.php @@ -7,6 +7,7 @@ namespace Drupal\user\Tests; +use Drupal\Core\Url; use Drupal\simpletest\WebTestBase; use Drupal\user\Entity\User; only in patch2: unchanged: --- a/core/profiles/standard/src/Tests/StandardTest.php +++ b/core/profiles/standard/src/Tests/StandardTest.php @@ -203,5 +203,15 @@ function testStandard() { $this->drupalGet($url); $this->drupalGet($url); $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'User profile page is cached by Dynamic Page Cache.'); + + $this->drupalLogout(); + $this->drupalGet('admin'); + $this->assertResponse('403'); + $base_url = \Drupal::service('request_stack')->getMasterRequest()->getBaseUrl(); + $desination = 'admin'; + if ($base_url) { + $desination = $base_url . '/' . $desination; + } + $this->assertLinkByHref(Url::fromRoute('user.login', [], ['query' => ['destination' => $desination]])->toString()); } }