From: Alexander Ebert Date: Tue, 8 Jan 2013 18:30:03 +0000 (+0100) Subject: Option names are now globally unique X-Git-Tag: 2.0.0_Beta_1~575 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0eafcb83f6250ea9cb6ce6b38581551481eb17c8;p=GitHub%2FWoltLab%2FWCF.git Option names are now globally unique Every application has to prepend it's own abbreviation to an option name, e.g. "wbb_thread_enable_marking_as_done" ("wbb_"). This is no longer done by WCF itself! Fixes #997 --- diff --git a/wcfsetup/install/files/lib/data/option/Option.class.php b/wcfsetup/install/files/lib/data/option/Option.class.php index 6d35e2d566..48eeda79cb 100644 --- a/wcfsetup/install/files/lib/data/option/Option.class.php +++ b/wcfsetup/install/files/lib/data/option/Option.class.php @@ -58,12 +58,12 @@ class Option extends DatabaseObject { * @return array */ public static function getOptions() { - $sql = "SELECT option_table.*, package.package, package.isApplication - FROM wcf".WCF_N."_option option_table - LEFT JOIN wcf".WCF_N."_package package - ON (package.packageID = option_table.packageID)"; + $sql = "SELECT * + FROM wcf".WCF_N."_option"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(); + + $options = array(); while ($row = $statement->fetchArray()) { $option = new Option(null, $row); $options[$option->getConstantName()] = $option; @@ -174,11 +174,6 @@ class Option extends DatabaseObject { * @return string */ public function getConstantName() { - $prefix = ''; - if ($this->package && $this->isApplication && $this->package != 'com.woltlab.wcf') { - $prefix = Package::getAbbreviation($this->package) . '_'; - } - - return strtoupper($prefix.$this->optionName); + return strtoupper($this->optionName); } } diff --git a/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php index 3fca93e149..6e80df3df8 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php @@ -11,7 +11,7 @@ use wcf\util\StringUtil; * Installs, updates and deletes options. * * @author Benjamin Kunz - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.package.plugin @@ -89,12 +89,10 @@ class OptionPackageInstallationPlugin extends AbstractOptionPackageInstallationP // try to find an existing option for updating $sql = "SELECT * FROM wcf".WCF_N."_".$this->tableName." - WHERE optionName = ? - AND packageID = ?"; + WHERE optionName = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array( - $optionName, - $this->installation->getPackageID() + $optionName )); $row = $statement->fetchArray(); @@ -107,6 +105,11 @@ class OptionPackageInstallationPlugin extends AbstractOptionPackageInstallationP OptionEditor::create($data); } else { + // editing an option from a different package + if ($row['packageID'] != $this->installation->getPackageID()) { + throw new SystemException("Option '".$optionName."' already exists, but is owned by a different package"); + } + // update existing item $optionObj = new Option(null, $row); $optionEditor = new OptionEditor($optionObj); diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index 4316a89e54..cf3e352373 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -324,7 +324,8 @@ CREATE TABLE wcf1_option ( supportI18n TINYINT(1) NOT NULL DEFAULT 0, requireI18n TINYINT(1) NOT NULL DEFAULT 0, additionalData MEDIUMTEXT, - UNIQUE KEY optionName (optionName, packageID) + + UNIQUE KEY optionName (optionName) ); DROP TABLE IF EXISTS wcf1_option_category;