From 471de6c1320de8882c133fa0a192266333afe1a3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 1 Jun 2022 15:05:08 +0200 Subject: [PATCH] Simplify RoutingCacheBuilder::getLandingPage() Reduce the amount of special handling required for the 'wcf' app. --- .../builder/RoutingCacheBuilder.class.php | 46 ++++++++----------- 1 file changed, 18 insertions(+), 28 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 3d99aded67..e05ca45378 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php @@ -4,6 +4,7 @@ namespace wcf\system\cache\builder; use wcf\data\application\Application; use wcf\data\page\PageCache; +use wcf\page\ArticleListPage; use wcf\page\CmsPage; use wcf\system\application\ApplicationHandler; use wcf\system\language\LanguageFactory; @@ -343,37 +344,26 @@ class RoutingCacheBuilder extends AbstractCacheBuilder $controller = null; - if ($application->packageID == 1) { - // handle WCF - $page = PageCacheBuilder::getInstance()->getData([], 'landingPage'); - if ($page->controller) { - $controller = $page->controller; - } else { - $controller = '__WCF_CMS__' . $page->pageID; - $controller = [ - 'controller' => $controller, - 'routePart' => $controller, - 'className' => CmsPage::class, - ]; - } - } else { - if ($application->landingPageID) { - $page = PageCache::getInstance()->getPage($application->landingPageID); - if ($page !== null) { - if ($page->controller) { - $controller = $page->controller; - } else { - $controller = '__WCF_CMS__' . $page->pageID; - $controller = [ - 'controller' => $controller, - 'routePart' => $controller, - 'className' => CmsPage::class, - ]; - } + if ($application->landingPageID) { + $page = PageCache::getInstance()->getPage($application->landingPageID); + if ($page !== null) { + if ($page->controller) { + $controller = $page->controller; + } else { + $controller = '__WCF_CMS__' . $page->pageID; + $controller = [ + 'controller' => $controller, + 'routePart' => $controller, + 'className' => CmsPage::class, + ]; } } + } - if ($controller === null) { + if ($controller === null) { + if ($application->getAbbreviation() === 'wcf') { + $controller = ArticleListPage::class; + } else { $controller = WCF::getApplicationObject($application)->getPrimaryController(); } } -- 2.20.1