Remove the need to rebuild the active application
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 6 Jul 2021 10:11:09 +0000 (12:11 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 6 Jul 2021 10:14:20 +0000 (12:14 +0200)
Calculating this value live does not come with a relevant performance loss and
simplifies the request handling logic.

wcfsetup/install/files/lib/system/application/AbstractApplication.class.php
wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php
wcfsetup/install/files/lib/system/request/RequestHandler.class.php

index 534f3fdde43f82567416d43b66eff185084513e9..03bada671cf9f042da4e799f91980067b4d5acaa 100644 (file)
@@ -36,8 +36,7 @@ abstract class AbstractApplication extends SingletonFactory implements IApplicat
     protected $evaluationPluginStoreID = 0;
 
     /**
-     * true, if current application is active (directly invoked, not dependent)
-     * @var bool
+     * @deprecated 5.5 - This value is unused and will always be 'false'. The 'active' status is determined live.
      */
     protected $isActiveApplication = false;
 
@@ -71,8 +70,6 @@ abstract class AbstractApplication extends SingletonFactory implements IApplicat
         }
 
         $this->packageID = $application->packageID;
-
-        $this->rebuildActiveApplication();
     }
 
     /**
@@ -88,7 +85,7 @@ abstract class AbstractApplication extends SingletonFactory implements IApplicat
      */
     public function isActiveApplication()
     {
-        return $this->isActiveApplication;
+        return $this->packageID == ApplicationHandler::getInstance()->getActiveApplication()->packageID;
     }
 
     /**
@@ -127,10 +124,10 @@ abstract class AbstractApplication extends SingletonFactory implements IApplicat
 
     /**
      * @since 5.2
+     * @deprecated 5.5 - This function is a noop. The 'active' status is determined live.
      */
     public function rebuildActiveApplication()
     {
-        $this->isActiveApplication = ($this->packageID == ApplicationHandler::getInstance()->getActiveApplication()->packageID);
     }
 
     /**
index ecb4c514f20e9089b6a1b478880a059544224775..35737b9054c3d398fdd32e7f41c559eaf5eea344 100644 (file)
@@ -258,20 +258,10 @@ class ApplicationHandler extends SingletonFactory
 
     /**
      * @since 5.2
+     * @deprecated 5.5 - This function is a noop. The 'active' status is determined live.
      */
     public function rebuildActiveApplication()
     {
-        /** @var AbstractApplication $application */
-        foreach ($this->cache['application'] as $application) {
-            if ($application->getPackage()->package === 'com.woltlab.wcf') {
-                continue;
-            }
-
-            $appObject = WCF::getApplicationObject($application);
-            if ($appObject instanceof AbstractApplication) {
-                $appObject->rebuildActiveApplication();
-            }
-        }
     }
 
     /**
index 2f493a18d6d85e6a1b890abb0bfc4ac32befdd8f..aefd18574f1f6bdf2f2b4e4a9917119e1a3365b7 100644 (file)
@@ -218,8 +218,6 @@ class RequestHandler extends SingletonFactory
                     $this->activeRequest->setIsLandingPage();
                 }
             }
-
-            ApplicationHandler::getInstance()->rebuildActiveApplication();
         } catch (SystemException $e) {
             if (
                 \defined('ENABLE_DEBUG_MODE')