Fixes issue with SystemException during package installation
authorMatthias Schmidt <gravatronics@live.com>
Wed, 12 Jun 2013 15:46:42 +0000 (17:46 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 12 Jun 2013 15:46:42 +0000 (17:46 +0200)
wcfsetup/install/files/lib/system/package/plugin/SQLPackageInstallationPlugin.class.php

index 7499f45a7845552b8f94ef4ecf4bfefcf776a51b..1604cf46fba30afc77ce6a6bc97d0a97dc7ab654 100644 (file)
@@ -52,11 +52,30 @@ class SQLPackageInstallationPlugin extends AbstractPackageInstallationPlugin {
                        $parser = new PackageInstallationSQLParser($queries, $this->installation->getPackage(), $this->installation->getAction());
                        $conflicts = $parser->test();
                        if (!empty($conflicts) && (isset($conflicts['CREATE TABLE']) || isset($conflicts['DROP TABLE']))) {
-                               WCF::getTPL()->assign(array(
-                                       'conflicts' => $conflicts
-                               ));
+                               $unknownCreateTable = isset($conflicts['CREATE TABLE']) ? $conflicts['CREATE TABLE'] : array();
+                               $unknownDropTable = isset($conflicts['DROP TABLE']) ? $conflicts['DROP TABLE'] : array();
                                
-                               throw new SystemException(WCF::getTPL()->fetch('packageInstallationDatabaseConflict'));
+                               $errorMessage = "Can't";
+                               if (!empty($unknownDropTable)) {
+                                       $errorMessage .= " drop unknown table";
+                                       if (count($unknownDropTable) > 1) {
+                                               $errorMessage .= "s";
+                                       }
+                                       $errorMessage .= " '".implode("', '", $unknownDropTable)."'";
+                               }
+                               if (!empty($unknownCreateTable)) {
+                                       if (!empty($unknownDropTable)) {
+                                               $errorMessage .= " and can't";
+                                       }
+                                       
+                                       $errorMessage .= " overwrite unknown table";
+                                       if (count($unknownCreateTable) > 1) {
+                                               $errorMessage .= "s";
+                                       }
+                                       $errorMessage .= " '".implode("', '", $unknownCreateTable)."'";
+                               }
+                               
+                               throw new SystemException($errorMessage);
                        }
                        
                        // execute queries