From 1e079d0c69e3347d2560027e5261970da9ac7b8b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 6 Jul 2021 11:32:06 +0200 Subject: [PATCH] Move the check for expired app evaluations into a dedicated method --- .../system/request/RequestHandler.class.php | 56 +++++++++++-------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php index 78a0f8c15f..079d50424c 100644 --- a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php @@ -210,30 +210,7 @@ class RequestHandler extends SingletonFactory $metaData ); - // check if the controller matches an app that has an expired evaluation date - [$abbreviation] = \explode('\\', $this->getActiveRequest()->getClassName(), 2); - if ($abbreviation !== 'wcf') { - $applicationObject = ApplicationHandler::getInstance()->getApplication($abbreviation); - $endDate = WCF::getApplicationObject($applicationObject)->getEvaluationEndDate(); - if ($endDate && $endDate < TIME_NOW) { - $package = $applicationObject->getPackage(); - - $pluginStoreFileID = WCF::getApplicationObject($applicationObject)->getEvaluationPluginStoreID(); - $isWoltLab = false; - if ($pluginStoreFileID === 0 && \strpos($package->package, 'com.woltlab.') === 0) { - $isWoltLab = true; - } - - throw new NamedUserException(WCF::getLanguage()->getDynamicVariable( - 'wcf.acp.package.evaluation.expired', - [ - 'packageName' => $package->getName(), - 'pluginStoreFileID' => $pluginStoreFileID, - 'isWoltLab' => $isWoltLab, - ] - )); - } - } + $this->checkAppEvaluation(); if (!$this->isACPRequest()) { // determine if current request matches the landing page @@ -291,6 +268,37 @@ class RequestHandler extends SingletonFactory } } + /** + * @since 5.5 + */ + protected function checkAppEvaluation() + { + // check if the controller matches an app that has an expired evaluation date + [$abbreviation] = \explode('\\', $this->getActiveRequest()->getClassName(), 2); + if ($abbreviation !== 'wcf') { + $applicationObject = ApplicationHandler::getInstance()->getApplication($abbreviation); + $endDate = WCF::getApplicationObject($applicationObject)->getEvaluationEndDate(); + if ($endDate && $endDate < TIME_NOW) { + $package = $applicationObject->getPackage(); + + $pluginStoreFileID = WCF::getApplicationObject($applicationObject)->getEvaluationPluginStoreID(); + $isWoltLab = false; + if ($pluginStoreFileID === 0 && \strpos($package->package, 'com.woltlab.') === 0) { + $isWoltLab = true; + } + + throw new NamedUserException(WCF::getLanguage()->getDynamicVariable( + 'wcf.acp.package.evaluation.expired', + [ + 'packageName' => $package->getName(), + 'pluginStoreFileID' => $pluginStoreFileID, + 'isWoltLab' => $isWoltLab, + ] + )); + } + } + } + /** * Redirects to the actual URL, e.g. controller has been aliased or mistyped (boardlist instead of board-list). * -- 2.20.1