From 7eab60e7559e25a3095555dffc748436fb12eb9a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 15 Dec 2016 03:47:08 +0100 Subject: [PATCH] Fixed i18n cms page used as core's landing page --- .../builder/RoutingCacheBuilder.class.php | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php index 360f5d9859..758e713762 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php @@ -1,6 +1,7 @@ $this->getCaseInsensitiveControllers(), - 'customUrls' => $this->getCustomUrls(), 'landingPages' => $this->getLandingPages() ]; + + $data['customUrls'] = $this->getCustomUrls($data['landingPages']); + + return $data; } /** @@ -127,9 +131,10 @@ class RoutingCacheBuilder extends AbstractCacheBuilder { * Builds up a lookup and a reverse lookup list per application in order to resolve * custom page mappings. * + * @param array $landingPages * @return array */ - protected function getCustomUrls() { + protected function getCustomUrls(array $landingPages) { $data = [ 'lookup' => [], 'reverse' => [] @@ -159,6 +164,11 @@ class RoutingCacheBuilder extends AbstractCacheBuilder { $rows[] = $row; } + $cmsPageID = 0; + if (preg_match('~^__WCF_CMS__(\d+)$~', $landingPages['wcf'][0], $matches)) { + $cmsPageID = $matches[1]; + } + $abbreviations = []; foreach ($rows as $row) { $customUrl = FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash($row['controllerCustomURL'])); @@ -178,8 +188,17 @@ class RoutingCacheBuilder extends AbstractCacheBuilder { } else { $cmsIdentifier = '__WCF_CMS__' . $row['pageID'] . '-' . ($row['languageID'] ?: 0); - $data['lookup'][$abbreviations[$packageID]][$customUrl] = $cmsIdentifier; + $data['reverse'][$abbreviations[$packageID]][$cmsIdentifier] = $customUrl; + + if ($cmsPageID && $abbreviations[$packageID] === 'wcf') { + if ($customUrl === '' && $cmsPageID != $row['pageID']) { + continue; + } + } + + $data['lookup'][$abbreviations[$packageID]][$customUrl] = $cmsIdentifier; + } } -- 2.20.1