Fix uninstallation of plugins with versionable database object
authorray176 <ray176@me.com>
Mon, 12 Aug 2013 09:52:07 +0000 (11:52 +0200)
committerray176 <ray176@me.com>
Mon, 12 Aug 2013 09:52:07 +0000 (11:52 +0200)
wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php

index 3ec6b0058b52a9e6979e5336b361be2cba2d1f7b..2c0e8a03705c92f70d94ba6940c1afbb70327bc6 100644 (file)
@@ -1038,7 +1038,11 @@ class PackageInstallationDispatcher {
                $versionTableBaseColumns[] = array('name' => 'versionTime', 'data' => array('type' => 'INT', 'length' => 10));
                
                foreach ($objectTypes as $objectType) {
-                       // get structure of base table
+                       if (!class_exists($objectType->className)) {
+                               // versionable database object isn't available anymore
+                               // the object type gets deleted later on during the uninstallation
+                               continue;
+                       }
                        $baseTableColumns = WCF::getDB()->getEditor()->getColumns(call_user_func(array($objectType->className, 'getDatabaseTableName')));
 
                        // remove primary key from base table columns
@@ -1059,6 +1063,16 @@ class PackageInstallationDispatcher {
                        if (empty($versionTableColumns)) {
                                $columns = array_merge($versionTableBaseColumns, $baseTableColumns);
                                WCF::getDB()->getEditor()->createTable(call_user_func(array($objectType->className, 'getDatabaseVersionTableName')), $columns);
+
+                               // add version table to plugin
+                               $sql = "INSERT INTO     wcf".WCF_N."_package_installation_sql_log
+                                                       (packageID, sqlTable)
+                                       VALUES          (?, ?)";
+                               $statement = WCF::getDB()->prepareStatement($sql);
+                               $statement->execute(array(
+                                       $this->queue->packageID,
+                                       call_user_func(array($objectType->className, 'getDatabaseVersionTableName'))
+                               ));
                        }
                        else {
                                // check garbage columns in versioned table