diff --git a/core/core.services.yml b/core/core.services.yml index b4bd43a..283d42a 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -506,7 +506,7 @@ services: - [setContext, ['@?router.request_context']] url_generator: class: Drupal\Core\Routing\CachedUrlGenerator - arguments: ['@url_generator.uncached', '@cache.url_generator', '@language_manager', '@router.route_provider', '@request_stack'] + arguments: ['@url_generator.uncached', '@cache.url_generator', '@router.route_provider', '@request_stack'] tags: - { name: needs_destruction } unrouted_url_assembler: diff --git a/core/lib/Drupal/Core/Routing/CachedUrlGenerator.php b/core/lib/Drupal/Core/Routing/CachedUrlGenerator.php index b235320..597ebfa 100644 --- a/core/lib/Drupal/Core/Routing/CachedUrlGenerator.php +++ b/core/lib/Drupal/Core/Routing/CachedUrlGenerator.php @@ -82,30 +82,18 @@ class CachedUrlGenerator implements DestructableInterface, CachedUrlGeneratorInt * The wrapped URL generator * @param \Drupal\Core\Cache\CacheBackendInterface $cache * The cache backend. - * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The language manager. * @param \Symfony\Cmf\Component\Routing\RouteProviderInterface $route_provider * The route provider. * @param Symfony\Component\HttpFoundation\RequestStack * The request stack. */ - public function __construct(UrlGeneratorInterface $url_generator, CacheBackendInterface $cache, LanguageManagerInterface $language_manager, SymfonyRouteProviderInterface $route_provider, RequestStack $request_stack) { + public function __construct(UrlGeneratorInterface $url_generator, CacheBackendInterface $cache, SymfonyRouteProviderInterface $route_provider, RequestStack $request_stack) { $this->urlGenerator = $url_generator; $this->cache = $cache; $this->routeProvider = $route_provider; // Select cache. - $this->cacheKey = $request_stack->getCurrentRequest()->attributes->get('_system_path'); - if ( is_null($this->cacheKey) ){ - $this->cacheKey = 'No match'; - } - if (!RequestHelper::isCleanUrl($request_stack->getCurrentRequest())){ - $this->cacheKey .= '::' . $request_stack->getCurrentRequest()->getScriptName(); - } - // Only multilingual sites have language dependant URLs. - if ($language_manager->isMultilingual()) { - $this->cacheKey .= '::' . $language_manager->getCurrentLanguage(Language::TYPE_URL)->getId(); - } + $this->cacheKey = $request_stack->getCurrentRequest()->getUri(); // Retrieve stored URLs $cached = $this->cache->get($this->cacheKey); diff --git a/core/tests/Drupal/Tests/Core/Routing/CachedUrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/CachedUrlGeneratorTest.php index 20edd23..2b96bf8 100644 --- a/core/tests/Drupal/Tests/Core/Routing/CachedUrlGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/CachedUrlGeneratorTest.php @@ -77,7 +77,6 @@ protected function setUp() { $this->urlGenerator = $this->getMock('Drupal\Core\Routing\UrlGeneratorInterface'); $this->cache = $this->getMock('Drupal\Core\Cache\CacheBackendInterface'); - $this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); $this->routeProvider = $this->getMock('Symfony\Cmf\Component\Routing\RouteProviderInterface'); $this->route = $this->getMockBuilder('Symfony\Component\Routing\Route') ->disableOriginalConstructor() @@ -87,7 +86,7 @@ protected function setUp() { ->willReturn($this->route); $this->requestStack = new RequestStack(); $this->requestStack->push(new Request()); - $this->cachedUrlGenerator = new CachedUrlGenerator($this->urlGenerator, $this->cache, $this->languageManager, $this->routeProvider, $this->requestStack); + $this->cachedUrlGenerator = new CachedUrlGenerator($this->urlGenerator, $this->cache, $this->routeProvider, $this->requestStack); } /**