core/lib/Drupal/Core/Path/PathValidator.php | 6 ++++-- core/tests/Drupal/KernelTests/Core/Path/PathValidatorTest.php | 10 ++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/core/lib/Drupal/Core/Path/PathValidator.php b/core/lib/Drupal/Core/Path/PathValidator.php index efce473..96de50a 100644 --- a/core/lib/Drupal/Core/Path/PathValidator.php +++ b/core/lib/Drupal/Core/Path/PathValidator.php @@ -153,7 +153,7 @@ protected function getPathAttributes($path, Request $request, $access_check) { $router = $this->accessAwareRouter; } - $initial_request_context = $router->getContext() ? $router->getContext() : new RequestContext(); + $existing_request_context = $router->getContext(); $path = $this->pathProcessor->processInbound('/' . $path, $request); try { @@ -175,7 +175,9 @@ protected function getPathAttributes($path, Request $request, $access_check) { $result = FALSE; } - $router->setContext($initial_request_context); + if ($existing_request_context) { + $router->setContext($existing_request_context); + } return $result; } diff --git a/core/tests/Drupal/KernelTests/Core/Path/PathValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Path/PathValidatorTest.php index a3cd7ea..a7e6122 100644 --- a/core/tests/Drupal/KernelTests/Core/Path/PathValidatorTest.php +++ b/core/tests/Drupal/KernelTests/Core/Path/PathValidatorTest.php @@ -1,16 +1,10 @@ setMethod($method); - /** @var Url $url */ + /** @var \Drupal\Core\Url $url */ $url = $pathValidator->getUrlIfValidWithoutAccessCheck($entity->toUrl()->toString()); $this->assertEquals($method, $requestContext->getMethod()); $this->assertInstanceOf(Url::class, $url);