Merge branch '2.1'
authorMatthias Schmidt <gravatronics@live.com>
Sun, 11 Jun 2017 09:11:52 +0000 (11:11 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 11 Jun 2017 09:12:15 +0000 (11:12 +0200)
1  2 
wcfsetup/install/files/lib/data/category/CategoryAction.class.php
wcfsetup/install/files/lib/data/label/group/LabelGroupAction.class.php

index 2c47fad0653d72141ec0ad158e56f9d9c5a4aa78,ca411538510d18210206f625e10aaaf63b5b284c..1e15e77a4beabe09bbdb76f189755f21dd3009a9
@@@ -41,8 -41,41 +43,38 @@@ class CategoryAction extends AbstractDa
        public function delete() {
                $returnValue = parent::delete();
                
 -                      $languageVariables = array();
+               // delete language items
+               if (!empty($this->objects)) {
+                       // identify i18n labels
 -                              $conditions->add('languageItem IN (?)', array($languageVariables));
++                      $languageVariables = [];
+                       foreach ($this->objects as $category) {
+                               if ($category->title === $category->getProcessor()->getI18nLangVarPrefix() . '.title.category' . $category->categoryID) {
+                                       $languageVariables[] = $category->title;
+                               }
+                               if ($category->description === $category->getProcessor()->getI18nLangVarPrefix() . '.description.category' . $category->categoryID) {
+                                       $languageVariables[] = $category->description;
+                               }
+                       }
+                       
+                       // remove language variables
+                       if (!empty($languageVariables)) {
+                               $conditions = new PreparedStatementConditionBuilder();
 -                              $languageItemIDs = array();
 -                              while ($row = $statement->fetchArray()) {
 -                                      $languageItemIDs[] = $row['languageItemID'];
 -                              }
++                              $conditions->add('languageItem IN (?)', [$languageVariables]);
+                               
+                               $sql = "SELECT  languageItemID
+                                       FROM    wcf".WCF_N."_language_item
+                                       ".$conditions;
+                               $statement = WCF::getDB()->prepareStatement($sql);
+                               $statement->execute($conditions->getParameters());
++                              $languageItemIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
+                               
+                               $objectAction = new LanguageItemAction($languageItemIDs, 'delete');
+                               $objectAction->executeAction();
+                       }
+               }
+               
                // call category types
 -              foreach ($this->objects as $categoryEditor) {
 +              foreach ($this->getObjects() as $categoryEditor) {
                        $categoryEditor->getProcessor()->afterDeletion($categoryEditor);
                }
                
index 9291dcccb2a4476c2afbbec886cff3c8f31cbf87,fc61a94307549653d4c7fa8eef115db1b392d10b..f78a7628455860400c05a53f5564f39aa1702ef8
@@@ -47,6 -48,35 +50,32 @@@ class LabelGroupAction extends Abstract
        public function delete() {
                $count = parent::delete();
                
 -                      $languageVariables = array();
+               if (!empty($this->objects)) {
+                       // identify i18n labels
 -                              $conditions->add('languageItem IN (?)', array($languageVariables));
++                      $languageVariables = [];
+                       foreach ($this->objects as $labelGroup) {
+                               if ($labelGroup->groupName === 'wcf.acp.label.group' . $labelGroup->groupID) {
+                                       $languageVariables[] = $labelGroup->groupName;
+                               }
+                       }
+                       
+                       // remove language variables
+                       if (!empty($languageVariables)) {
+                               $conditions = new PreparedStatementConditionBuilder();
 -                              $languageItemIDs = array();
 -                              while ($row = $statement->fetchArray()) {
 -                                      $languageItemIDs[] = $row['languageItemID'];
 -                              }
++                              $conditions->add('languageItem IN (?)', [$languageVariables]);
+                               
+                               $sql = "SELECT  languageItemID
+                                       FROM    wcf".WCF_N."_language_item
+                                       ".$conditions;
+                               $statement = WCF::getDB()->prepareStatement($sql);
+                               $statement->execute($conditions->getParameters());
++                              $languageItemIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
+                               
+                               $objectAction = new LanguageItemAction($languageItemIDs, 'delete');
+                               $objectAction->executeAction();
+                       }
+               }
+               
                foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.label.objectType') as $objectType) {
                        $objectType->getProcessor()->save();
                }