From cca83e49ba349ad1b9f6bce8622116439b6bf665 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Fri, 22 Jul 2016 13:24:17 +0200 Subject: [PATCH] Fixed creation of option categories during package updates --- ...tOptionPackageInstallationPlugin.class.php | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php index 3c34e482fd..f58f731fb2 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php @@ -127,7 +127,7 @@ abstract class AbstractOptionPackageInstallationPlugin extends AbstractXMLPackag ]; // adjust show order - if ($data['showOrder'] !== null || $this->installation->getAction() != 'update') { + if ($data['showOrder'] !== null || $this->installation->getAction() != 'update' || $this->getExistingCategory($element->getAttribute('name')) === false) { $data['showOrder'] = $this->getShowOrder($data['showOrder'], $data['parentCategoryName'], 'parentCategoryName', '_category'); } @@ -202,13 +202,12 @@ abstract class AbstractOptionPackageInstallationPlugin extends AbstractXMLPackag } /** - * Installs option categories. + * Returns the category with given name. * - * @param array $category - * @throws SystemException + * @param string $category + * @return array|false */ - protected function saveCategory($category) { - // search existing category + protected function getExistingCategory($category) { $sql = "SELECT categoryID, packageID FROM ".$this->application.WCF_N."_".$this->tableName."_category WHERE categoryName = ?"; @@ -216,7 +215,18 @@ abstract class AbstractOptionPackageInstallationPlugin extends AbstractXMLPackag $statement->execute([ $category['categoryName'] ]); - $row = $statement->fetchArray(); + return $statement->fetchArray(); + } + + /** + * Installs option categories. + * + * @param array $category + * @throws SystemException + */ + protected function saveCategory($category) { + // search existing category + $row = $this->getExistingCategory($category); if (empty($row['categoryID'])) { // insert new category $sql = "INSERT INTO ".$this->application.WCF_N."_".$this->tableName."_category -- 2.20.1