Force disable the HTML bbcode on upgrade
authorAlexander Ebert <ebert@woltlab.com>
Thu, 7 Sep 2017 12:42:18 +0000 (14:42 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 7 Sep 2017 12:42:18 +0000 (14:42 +0200)
Fixes #2388

com.woltlab.wcf/package.xml
wcfsetup/install/files/acp/update_com.woltlab.wcf_3.1_postUpgrade.php [new file with mode: 0644]

index 70e35347b46a3c27971a3f1c5f8dca3a4da04a5a..659e520f7dd29df13b5d5c15e28b58c12efcb5a1 100644 (file)
@@ -84,6 +84,8 @@
                <instruction type="mediaProvider" />
                
                <instruction type="style">defaultStyle.tar</instruction>
+               
+               <instruction type="script" run="standalone" flushCache="false">acp/update_com.woltlab.wcf_3.1_postUpgrade.php</instruction>
        </instructions>
        
        <instructions type="update" fromversion="3.1.0 Alpha 1">
diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.1_postUpgrade.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.1_postUpgrade.php
new file mode 100644 (file)
index 0000000..bb273ef
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+use wcf\system\WCF;
+
+/**
+ * @author     Alexander Ebert
+ * @copyright  2001-2017 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core
+ */
+// force disable of HTML bbcode for all groups
+$sql = "UPDATE  wcf".WCF_N."_user_group_option_value
+       SET     optionValue = ?
+       WHERE   groupID = ?
+               AND optionID = ?";
+$updateStatement = WCF::getDB()->prepareStatement($sql);
+
+$sql = "SELECT  *
+       FROM    wcf".WCF_N."_user_group_option_value
+       WHERE   optionID IN (
+                       SELECT  optionID
+                       FROM    wcf".WCF_N."_user_group_option
+                       WHERE   optionType = ?
+               )";
+$statement = WCF::getDB()->prepareStatement($sql);
+$statement->execute(['BBCodeSelect']);
+
+WCF::getDB()->beginTransaction();
+while ($row = $statement->fetchArray()) {
+       $value = $row['optionValue'];
+       if (!empty($value)) $value .= ',';
+       $value .= 'html';
+       
+       $updateStatement->execute([
+               $value,
+               $row['groupID'],
+               $row['optionID']
+       ]);
+}
+WCF::getDB()->commitTransaction();