diff --git a/src/Kunstmaan/MultiDomainBundle/Router/DomainBasedLocaleRouter.php b/src/Kunstmaan/MultiDomainBundle/Router/DomainBasedLocaleRouter.php index 08162a0d47..2a8f5db856 100644 --- a/src/Kunstmaan/MultiDomainBundle/Router/DomainBasedLocaleRouter.php +++ b/src/Kunstmaan/MultiDomainBundle/Router/DomainBasedLocaleRouter.php @@ -105,24 +105,25 @@ protected function getRequestLocale() protected function getNodeTranslation($matchResult) { $key = $matchResult['_controller'] . $matchResult['url'] . $matchResult['_locale'] . $matchResult['_route']; - if (!isset($this->cachedNodeTranslations[$key])) { - $rootNode = $this->domainConfiguration->getRootNode(); - - // Lookup node translation - $nodeTranslationRepo = $this->getNodeTranslationRepository(); - - /* @var NodeTranslation $nodeTranslation */ - $nodeTranslation = $nodeTranslationRepo->getNodeTranslationForUrl( - $matchResult['url'], - $matchResult['_locale'], - false, - null, - $rootNode - ); - $this->cachedNodeTranslations[$key] = $nodeTranslation; + if (\array_key_exists($key, $this->cachedNodeTranslations)) { + return $this->cachedNodeTranslations[$key]; } - return $this->cachedNodeTranslations[$key]; + $rootNode = $this->domainConfiguration->getRootNode(); + + // Lookup node translation + $nodeTranslationRepo = $this->getNodeTranslationRepository(); + + /* @var NodeTranslation $nodeTranslation */ + $nodeTranslation = $nodeTranslationRepo->getNodeTranslationForUrl( + $matchResult['url'], + $matchResult['_locale'], + false, + null, + $rootNode + ); + + return $this->cachedNodeTranslations[$key] = $nodeTranslation; } private function isMultiDomainHost(): bool