From eeae8f3b4370fc15edadb09b5a5705531274599e Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 15 Apr 2013 20:39:41 +0200 Subject: [PATCH] Fixes replacement of table prefixes If a package, that is no application, requires an application (in WCF 1, this would have been a plugin), only the `wcf1_` prefix is replaced, thus altering existing application tables or creating new application tables isn't possible. This commit now replaces app1_ with app{WCF_N}_ for all installed applications. --- .../SQLPackageInstallationPlugin.class.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/wcfsetup/install/files/lib/system/package/plugin/SQLPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/SQLPackageInstallationPlugin.class.php index be39869d4e..54c8bb1d1b 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/SQLPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/SQLPackageInstallationPlugin.class.php @@ -1,6 +1,7 @@ getSQL($this->instruction['value'])) { $package = $this->installation->getPackage(); - if ($package->isApplication == 1) { - // package is application - $packageAbbr = Package::getAbbreviation($package->package); - $tablePrefix = WCF_N.'_'; + + // replace app1_ with app{WCF_N}_ in the table names for + // all applications + $packageList = new PackageList(); + $packageList->getConditionBuilder()->add('package.isApplication = ?', array(1)); + $packageList->readObjects(); + foreach ($packageList as $package) { + $abbreviation = Package::getAbbreviation($package->package); - // Replace the variable xyz1_1 with $tablePrefix in the table names. - $queries = StringUtil::replace($packageAbbr.'1_', $packageAbbr.$tablePrefix, $queries); + $queries = StringUtil::replace($abbreviation.'1_', $abbreviation.WCF_N.'_', $queries); } - // replace wcf1_ with the actual WCF_N value - $queries = str_replace("wcf1_", "wcf".WCF_N."_", $queries); - // check queries $parser = new PackageInstallationSQLParser($queries, $this->installation->getPackage(), $this->installation->getAction()); $conflicts = $parser->test(); -- 2.20.1