Fixed uninstallation of apps
authorAlexander Ebert <ebert@woltlab.com>
Thu, 28 Jul 2016 11:14:44 +0000 (13:14 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 28 Jul 2016 11:14:51 +0000 (13:14 +0200)
wcfsetup/install/files/lib/acp/action/UninstallPackageAction.class.php
wcfsetup/install/files/lib/data/application/Application.class.php
wcfsetup/install/files/lib/data/application/ApplicationAction.class.php
wcfsetup/install/files/lib/system/WCF.class.php
wcfsetup/setup/db/install.sql

index 401ba56357646cfd696efb990583c4e1c3bfa983..9fe5af3b3d8e1fe6d9723efebf1db66c80ee12a4 100644 (file)
@@ -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),
index d9193d8cd412706370374be25c2ab6187df83181..5bf25e4befbc0f54dc88b476ed4bcbd12241a35b 100644 (file)
@@ -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 {
        /**
index da26b9553274dffc355236243512c7560da5c8b6..1abd3c21194b2df8bda76355aa2b9a351a9ed9bf 100644 (file)
@@ -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();
+       }
 }
index d76c23e2f37d5f47a135640ba7dd42f11125ec01..f4152bc89a1c27aac3e28d5e03a6116a1e1e7042 100644 (file)
@@ -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);
                }
index cf58e87b00409d50c339222690abaa0c256d0a8d..cd8931573f02bccc3b0b254d9946ca8b908d2c77 100644 (file)
@@ -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;