Import the new options first
authorAlexander Ebert <ebert@woltlab.com>
Fri, 19 Jul 2019 09:58:56 +0000 (11:58 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 19 Jul 2019 09:58:56 +0000 (11:58 +0200)
com.woltlab.wcf/files_reloadOptions.tar [new file with mode: 0644]
com.woltlab.wcf/package.xml
wcfsetup/install/files/acp/update-com.woltlab.wcf_3.2_reactionUpdate.php [deleted file]
wcfsetup/install/files/acp/update-com.woltlab.wcf_5.2_reactionUpdate.php [new file with mode: 0644]
wcfsetup/install/files/acp/update-com.woltlab.wcf_5.2_reloadOptions.php [new file with mode: 0644]

diff --git a/com.woltlab.wcf/files_reloadOptions.tar b/com.woltlab.wcf/files_reloadOptions.tar
new file mode 100644 (file)
index 0000000..67eeeab
Binary files /dev/null and b/com.woltlab.wcf/files_reloadOptions.tar differ
index 9b5a151c6f342ff306c64a2a8cc2d08e652b7c16..35707f5bc0abac812621886b8f87004b9caeb0e1 100644 (file)
        </instructions>
        
        <instructions type="update" fromversion="5.2.0 Alpha 1">
+               <!-- Import the new options first -->
+               <instruction type="option" />
+               <instruction type="file">files_reloadOptions.tar</instruction>
+               <instruction type="script" run="standalone">acp/update-com.woltlab.wcf_5.2_reloadOptions.php</instruction>
+               
                <instruction type="acpTemplate">acptemplates_update.tar</instruction>
                <instruction type="file">files_update.tar</instruction>
                <instruction type="template">templates_update.tar</instruction>
@@ -61,7 +66,6 @@
                
                <instruction type="box" />
                <instruction type="objectType" />
-               <instruction type="option" />
                <instruction type="page" />
        </instructions>
 </package>
diff --git a/wcfsetup/install/files/acp/update-com.woltlab.wcf_3.2_reactionUpdate.php b/wcfsetup/install/files/acp/update-com.woltlab.wcf_3.2_reactionUpdate.php
deleted file mode 100644 (file)
index 2a335ba..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-<?php
-use wcf\data\language\item\LanguageItemEditor;
-use wcf\data\like\Like;
-use wcf\data\option\OptionEditor;
-use wcf\system\language\LanguageFactory;
-use wcf\system\WCF;
-
-// !!!!!!!!!
-// HEADS UP!    The columns for wcf1_like, wcf1_like_object and the wcf1_reaction_type table must already exists, before calling this script.
-// HEADS UP!    The foreign key for the wcf1_like table will be created within this script, after providing real values for the reactionTypeID
-// HEADS UP!    column. Also this script provides the basic reactionTypes.
-// !!!!!!!!!
-
-/**
- * @author     Joshua Ruesweg
- * @copyright  2001-2019 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core
- */
-
-OptionEditor::import([
-       'like_show_summary' => 1,
-]);
-
-try {
-       WCF::getDB()->beginTransaction();
-       
-       $reactions = ['like', 'thanks', 'haha', 'confused', 'sad'];
-       if (LIKE_ENABLE_DISLIKE) {
-               $reactions[] = 'thumbsDown';
-               
-               $sql = "SELECT  languageCategoryID
-                       FROM    wcf".WCF_N."_language_category
-                       WHERE   languageCategory = ?";
-               $statement = WCF::getDB()->prepareStatement($sql, 1);
-               $statement->execute(['wcf.reactionType']);
-               $languageCategoryID = $statement->fetchSingleColumn();
-               
-               // Create a custom phrase for this reaction, it needs to be "manually" added
-               // because it would otherwise conflict with the next reaction created by the
-               // user, *if* there are no dislikes.
-               foreach (LanguageFactory::getInstance()->getLanguages() as $language) {
-                       LanguageItemEditor::create([
-                               'languageID' => $language->languageID,
-                               'languageItem' => 'wcf.reactionType.title6',
-                               'languageItemValue' => ($language->getFixedLanguageCode() === 'de' ? 'Gefällt mir nicht' : 'Dislike'),
-                               'languageCategoryID' => $languageCategoryID,
-                               'packageID' => 1,
-                       ]);
-               }
-       }
-       
-       $sql = "INSERT INTO     wcf".WCF_N."_reaction_type
-                               (reactionTypeID, title, showOrder, iconFile)
-               VALUES          (?, ?, ?, ?)";
-       $statement = WCF::getDB()->prepareStatement($sql);
-       for ($i = 0, $length = count($reactions); $i < $length; $i++) {
-               $reactionTypeID = $i + 1;
-               
-               $statement->execute([
-                       $reactionTypeID,
-                       "wcf.reactionType.title{$reactionTypeID}",
-                       $reactionTypeID,
-                       "{$reactions[$i]}.svg",
-               ]);
-       }
-       
-       // Update the existing (dis)likes.
-       $likeValues = [Like::LIKE => 1];
-       if (LIKE_ENABLE_DISLIKE) $likeValues[Like::DISLIKE] = 6;
-       
-       $sql = "UPDATE  wcf".WCF_N."_like
-               SET     reactionTypeID = ?
-               WHERE   likeValue = ?";
-       $statement = WCF::getDB()->prepareStatement($sql);
-       foreach ($likeValues as $likeValue => $reactionTypeID) {
-               $statement->execute([
-                       $reactionTypeID,
-                       $likeValue,
-               ]);
-       }
-       
-       // Delete outdated or unsupported likes.
-       WCF::getDB()->prepareStatement("DELETE FROM wcf".WCF_N."_like WHERE reactionTypeID = 0")->execute();
-       
-       // Adjust the like objects by moving all dislikes into regular likes/cumulativeLikes.
-       $sql = "UPDATE  wcf".WCF_N."_like_object
-               SET     likes = likes + dislikes,
-                       cumulativeLikes = likes,
-                       dislikes = 0";
-       WCF::getDB()->prepareStatement($sql)->execute();
-       
-       $statement = WCF::getDB()->prepareStatement('ALTER TABLE wcf'.WCF_N.'_like ADD FOREIGN KEY (reactionTypeID) REFERENCES wcf1_reaction_type (reactionTypeID) ON DELETE CASCADE');
-       $statement->execute();
-       
-       WCF::getDB()->commitTransaction();
-}
-catch (Exception $e) {
-       WCF::getDB()->rollBackTransaction();
-       
-       throw $e;
-}
diff --git a/wcfsetup/install/files/acp/update-com.woltlab.wcf_5.2_reactionUpdate.php b/wcfsetup/install/files/acp/update-com.woltlab.wcf_5.2_reactionUpdate.php
new file mode 100644 (file)
index 0000000..2a335ba
--- /dev/null
@@ -0,0 +1,102 @@
+<?php
+use wcf\data\language\item\LanguageItemEditor;
+use wcf\data\like\Like;
+use wcf\data\option\OptionEditor;
+use wcf\system\language\LanguageFactory;
+use wcf\system\WCF;
+
+// !!!!!!!!!
+// HEADS UP!    The columns for wcf1_like, wcf1_like_object and the wcf1_reaction_type table must already exists, before calling this script.
+// HEADS UP!    The foreign key for the wcf1_like table will be created within this script, after providing real values for the reactionTypeID
+// HEADS UP!    column. Also this script provides the basic reactionTypes.
+// !!!!!!!!!
+
+/**
+ * @author     Joshua Ruesweg
+ * @copyright  2001-2019 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core
+ */
+
+OptionEditor::import([
+       'like_show_summary' => 1,
+]);
+
+try {
+       WCF::getDB()->beginTransaction();
+       
+       $reactions = ['like', 'thanks', 'haha', 'confused', 'sad'];
+       if (LIKE_ENABLE_DISLIKE) {
+               $reactions[] = 'thumbsDown';
+               
+               $sql = "SELECT  languageCategoryID
+                       FROM    wcf".WCF_N."_language_category
+                       WHERE   languageCategory = ?";
+               $statement = WCF::getDB()->prepareStatement($sql, 1);
+               $statement->execute(['wcf.reactionType']);
+               $languageCategoryID = $statement->fetchSingleColumn();
+               
+               // Create a custom phrase for this reaction, it needs to be "manually" added
+               // because it would otherwise conflict with the next reaction created by the
+               // user, *if* there are no dislikes.
+               foreach (LanguageFactory::getInstance()->getLanguages() as $language) {
+                       LanguageItemEditor::create([
+                               'languageID' => $language->languageID,
+                               'languageItem' => 'wcf.reactionType.title6',
+                               'languageItemValue' => ($language->getFixedLanguageCode() === 'de' ? 'Gefällt mir nicht' : 'Dislike'),
+                               'languageCategoryID' => $languageCategoryID,
+                               'packageID' => 1,
+                       ]);
+               }
+       }
+       
+       $sql = "INSERT INTO     wcf".WCF_N."_reaction_type
+                               (reactionTypeID, title, showOrder, iconFile)
+               VALUES          (?, ?, ?, ?)";
+       $statement = WCF::getDB()->prepareStatement($sql);
+       for ($i = 0, $length = count($reactions); $i < $length; $i++) {
+               $reactionTypeID = $i + 1;
+               
+               $statement->execute([
+                       $reactionTypeID,
+                       "wcf.reactionType.title{$reactionTypeID}",
+                       $reactionTypeID,
+                       "{$reactions[$i]}.svg",
+               ]);
+       }
+       
+       // Update the existing (dis)likes.
+       $likeValues = [Like::LIKE => 1];
+       if (LIKE_ENABLE_DISLIKE) $likeValues[Like::DISLIKE] = 6;
+       
+       $sql = "UPDATE  wcf".WCF_N."_like
+               SET     reactionTypeID = ?
+               WHERE   likeValue = ?";
+       $statement = WCF::getDB()->prepareStatement($sql);
+       foreach ($likeValues as $likeValue => $reactionTypeID) {
+               $statement->execute([
+                       $reactionTypeID,
+                       $likeValue,
+               ]);
+       }
+       
+       // Delete outdated or unsupported likes.
+       WCF::getDB()->prepareStatement("DELETE FROM wcf".WCF_N."_like WHERE reactionTypeID = 0")->execute();
+       
+       // Adjust the like objects by moving all dislikes into regular likes/cumulativeLikes.
+       $sql = "UPDATE  wcf".WCF_N."_like_object
+               SET     likes = likes + dislikes,
+                       cumulativeLikes = likes,
+                       dislikes = 0";
+       WCF::getDB()->prepareStatement($sql)->execute();
+       
+       $statement = WCF::getDB()->prepareStatement('ALTER TABLE wcf'.WCF_N.'_like ADD FOREIGN KEY (reactionTypeID) REFERENCES wcf1_reaction_type (reactionTypeID) ON DELETE CASCADE');
+       $statement->execute();
+       
+       WCF::getDB()->commitTransaction();
+}
+catch (Exception $e) {
+       WCF::getDB()->rollBackTransaction();
+       
+       throw $e;
+}
diff --git a/wcfsetup/install/files/acp/update-com.woltlab.wcf_5.2_reloadOptions.php b/wcfsetup/install/files/acp/update-com.woltlab.wcf_5.2_reloadOptions.php
new file mode 100644 (file)
index 0000000..ea2e7f4
--- /dev/null
@@ -0,0 +1,5 @@
+<?php
+namespace wcf\acp;
+use wcf\data\option\OptionEditor;
+
+OptionEditor::resetCache();