$this->packageID = $application->packageID;
- // check if current application is active (directly invoked, not dependent)
- if ($application->packageID == ApplicationHandler::getInstance()->getActiveApplication()->packageID) {
- $this->isActiveApplication = true;
- }
+ $this->rebuildActiveApplication();
}
/**
return $this->primaryController;
}
+ /**
+ * @since 5.2
+ */
+ public function rebuildActiveApplication() {
+ $this->isActiveApplication = ($this->packageID == ApplicationHandler::getInstance()->getActiveApplication()->packageID);
+ }
+
/**
* @inheritDoc
*/
use wcf\data\package\Package;
use wcf\data\package\PackageList;
use wcf\system\cache\builder\ApplicationCacheBuilder;
+use wcf\system\request\RequestHandler;
use wcf\system\request\RouteHandler;
use wcf\system\Regex;
use wcf\system\SingletonFactory;
+use wcf\system\WCF;
use wcf\util\FileUtil;
/**
return new Application(null, [
'domainName' => $host,
'domainPath' => $path,
- 'cookieDomain' => $host
+ 'cookieDomain' => $host,
]);
}
- else if (isset($this->cache['application'][PACKAGE_ID])) {
+
+ $request = RequestHandler::getInstance()->getActiveRequest();
+ if ($request !== null) {
+ $abbreviation = substr($request->getClassName(), 0, mb_strpos($request->getClassName(), '\\'));
+
+ return $this->getApplication($abbreviation);
+ }
+
+ if (isset($this->cache['application'][PACKAGE_ID])) {
return $this->cache['application'][PACKAGE_ID];
}
return $this->isMultiDomain;
}
+ /**
+ * @since 5.2
+ */
+ 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();
+ }
+ }
+ }
+
/**
* Rebuilds cookie domain/path for all applications.
*/