Improved handling of default controllers
authorAlexander Ebert <ebert@woltlab.com>
Mon, 6 Jul 2015 12:41:35 +0000 (14:41 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 6 Jul 2015 12:41:35 +0000 (14:41 +0200)
wcfsetup/install/files/lib/system/request/FlexibleRoute.class.php

index 02766ad230d60801535623bd6e542ca546700183..dc636992591ff46919c6b49cc5667209a5dcadbc 100644 (file)
@@ -41,6 +41,12 @@ class FlexibleRoute implements IRoute {
         */
        protected $pattern = '';
        
+       /**
+        * primary application's abbreviation (e.g. "wbb")
+        * @var string
+        */
+       protected $primaryApplication = '';
+       
        /**
         * list of required components
         * @var array<string>
@@ -140,22 +146,28 @@ class FlexibleRoute implements IRoute {
                        
                        if (!RequestHandler::getInstance()->isACPRequest()) {
                                $landingPage = PageMenu::getInstance()->getLandingPage();
-                               if ($landingPage !== null && strcasecmp($landingPage->getController(), $components['controller']) == 0) {
-                                       $ignoreController = true;
+                               if ($this->primaryApplication === '') {
+                                       $primaryApplication = ApplicationHandler::getInstance()->getPrimaryApplication();
+                                       $this->primaryApplication = ApplicationHandler::getInstance()->getAbbreviation($primaryApplication->packageID);
                                }
                                
-                               // check if this is the default controller of the requested application
-                               if (!$ignoreController && $application !== null) {
-                                       if (RouteHandler::getInstance()->getDefaultController($application) == $components['controller']) {
-                                               // check if this is the primary application and the landing page originates to the same application
-                                               $primaryApplication = ApplicationHandler::getInstance()->getPrimaryApplication();
-                                               $abbreviation = ApplicationHandler::getInstance()->getAbbreviation($primaryApplication->packageID);
-                                               if ($abbreviation == $application) {
-                                                       if ($landingPage === null || $landingPage->getController() === $components['controller']) {
-                                                               $ignoreController = true;
-                                                       }
+                               // check if this is the default controller
+                               if (strcasecmp(RouteHandler::getInstance()->getDefaultController($application), $components['controller']) === 0) {
+                                       // check if this matches the primary application
+                                       if ($this->primaryApplication === $application) {
+                                               if (strcasecmp($landingPage->getController(), $components['controller']) === 0) {
+                                                       // skip controller if it matches the default controller
+                                                       $ignoreController = true;
                                                }
                                        }
+                                       else {
+                                               // skip default controller
+                                               $ignoreController = true;
+                                       }
+                               }
+                               else if (strcasecmp($landingPage->getController(), $components['controller']) === 0) {
+                                       // landing page
+                                       $ignoreController = true;
                                }
                        }