From: Matthias Schmidt Date: Mon, 15 Apr 2013 18:39:41 +0000 (+0200) Subject: Fixes replacement of table prefixes X-Git-Tag: 2.0.0_Beta_1~214^2~3^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=eeae8f3b4370fc15edadb09b5a5705531274599e;p=GitHub%2FWoltLab%2FWCF.git 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. --- 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();