From: Alexander Ebert Date: Thu, 28 Jul 2016 11:14:44 +0000 (+0200) Subject: Fixed uninstallation of apps X-Git-Tag: 3.0.0_Beta_1~942 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f4eafe37f02d0cde6715acacf774fbd7c3902bce;p=GitHub%2FWoltLab%2FWCF.git Fixed uninstallation of apps --- diff --git a/wcfsetup/install/files/lib/acp/action/UninstallPackageAction.class.php b/wcfsetup/install/files/lib/acp/action/UninstallPackageAction.class.php index 401ba56357..9fe5af3b3d 100644 --- a/wcfsetup/install/files/lib/acp/action/UninstallPackageAction.class.php +++ b/wcfsetup/install/files/lib/acp/action/UninstallPackageAction.class.php @@ -2,6 +2,7 @@ namespace wcf\acp\action; use wcf\action\AbstractDialogAction; use wcf\data\application\Application; +use wcf\data\application\ApplicationAction; use wcf\data\package\installation\queue\PackageInstallationQueue; use wcf\data\package\installation\queue\PackageInstallationQueueEditor; use wcf\data\package\Package; @@ -84,6 +85,12 @@ class UninstallPackageAction extends InstallPackageAction { 'queue' => $queue ]); + // mark package as tainted if it is an app + if ($package->isApplication) { + $applicationAction = new ApplicationAction([$package->packageID], 'markAsTainted'); + $applicationAction->executeAction(); + } + $queueID = $this->installation->nodeBuilder->getQueueByNode($queue->processNo, $this->installation->nodeBuilder->getNextNode()); $this->data = [ 'template' => WCF::getTPL()->fetch($this->templateName), diff --git a/wcfsetup/install/files/lib/data/application/Application.class.php b/wcfsetup/install/files/lib/data/application/Application.class.php index d9193d8cd4..5bf25e4bef 100644 --- a/wcfsetup/install/files/lib/data/application/Application.class.php +++ b/wcfsetup/install/files/lib/data/application/Application.class.php @@ -22,6 +22,7 @@ use wcf\util\FileUtil; * @property-read string $domainPath * @property-read string $cookieDomain * @property-read string $cookiePath + * @property-read integer $isTainted */ class Application extends DatabaseObject { /** diff --git a/wcfsetup/install/files/lib/data/application/ApplicationAction.class.php b/wcfsetup/install/files/lib/data/application/ApplicationAction.class.php index da26b95532..1abd3c2119 100644 --- a/wcfsetup/install/files/lib/data/application/ApplicationAction.class.php +++ b/wcfsetup/install/files/lib/data/application/ApplicationAction.class.php @@ -104,4 +104,14 @@ class ApplicationAction extends AbstractDatabaseObjectAction { // reset application cache ApplicationCacheBuilder::getInstance()->reset(); } + + /** + * Marks an application as tainted, prevents loading it during uninstallation. + */ + public function markAsTainted() { + $applicationEditor = $this->getSingleObject(); + $applicationEditor->update(['isTainted' => 1]); + + ApplicationCacheBuilder::getInstance()->reset(); + } } diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index d76c23e2f3..f4152bc89a 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -460,11 +460,6 @@ class WCF { $this->getTPL()->assign('baseHref', self::$applications['wcf']->getPageURL()); } - // TODO: this is required for the uninstallation of applications, find a different solution! - if (PACKAGE_ID == 1) { - //return; - } - // start main application $application = ApplicationHandler::getInstance()->getActiveApplication(); if ($application->packageID != 1) { @@ -482,6 +477,10 @@ class WCF { // ignore WCF continue; } + else if ($application->isTainted) { + // ignore apps flagged for uninstallation + continue; + } $loadedApplications[] = $this->loadApplication($application, true); } diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index cf58e87b00..cd8931573f 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -149,7 +149,8 @@ CREATE TABLE wcf1_application ( domainName VARCHAR(255) NOT NULL, domainPath VARCHAR(255) NOT NULL DEFAULT '/', cookieDomain VARCHAR(255) NOT NULL, - cookiePath VARCHAR(255) NOT NULL DEFAULT '/' + cookiePath VARCHAR(255) NOT NULL DEFAULT '/', + isTainted TINYINT(1) NOT DEFAULT 0 ); DROP TABLE IF EXISTS wcf1_article;