Simplify RoutingCacheBuilder::getLandingPage()
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 1 Jun 2022 13:05:08 +0000 (15:05 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 1 Jun 2022 13:07:02 +0000 (15:07 +0200)
Reduce the amount of special handling required for the 'wcf' app.

wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php

index 3d99aded6701655584b8960c5e716d20cbd60cbc..e05ca45378397901462aa51047925ccdb1feecb8 100644 (file)
@@ -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();
                 }
             }