From: Alexander Ebert Date: Fri, 19 Jul 2019 09:58:56 +0000 (+0200) Subject: Import the new options first X-Git-Tag: 5.2.0_Alpha_2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=981505fe440824a36e76f338baeec1df87affa2d;p=GitHub%2FWoltLab%2FWCF.git Import the new options first --- diff --git a/com.woltlab.wcf/files_reloadOptions.tar b/com.woltlab.wcf/files_reloadOptions.tar new file mode 100644 index 0000000000..67eeeabc32 Binary files /dev/null and b/com.woltlab.wcf/files_reloadOptions.tar differ diff --git a/com.woltlab.wcf/package.xml b/com.woltlab.wcf/package.xml index 9b5a151c6f..35707f5bc0 100644 --- a/com.woltlab.wcf/package.xml +++ b/com.woltlab.wcf/package.xml @@ -51,6 +51,11 @@ + + + files_reloadOptions.tar + acp/update-com.woltlab.wcf_5.2_reloadOptions.php + acptemplates_update.tar files_update.tar templates_update.tar @@ -61,7 +66,6 @@ - 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 index 2a335baa80..0000000000 --- a/wcfsetup/install/files/acp/update-com.woltlab.wcf_3.2_reactionUpdate.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @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 index 0000000000..2a335baa80 --- /dev/null +++ b/wcfsetup/install/files/acp/update-com.woltlab.wcf_5.2_reactionUpdate.php @@ -0,0 +1,102 @@ + + * @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 index 0000000000..ea2e7f4610 --- /dev/null +++ b/wcfsetup/install/files/acp/update-com.woltlab.wcf_5.2_reloadOptions.php @@ -0,0 +1,5 @@ +