From 1238dfad4af8f94ea1c7aad09872fdf3d580cff5 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 3 Oct 2020 20:20:40 +0200 Subject: [PATCH] Removed the legacy database encoding converter Closes #3570 --- com.woltlab.wcf/files_pre.tar | Bin 4912128 -> 4913152 bytes com.woltlab.wcf/objectType.xml | 9 +- .../update_com.woltlab.wcf_5.3_preUpdate.php | 30 +++++- .../DatabaseConvertEncodingWorker.class.php | 93 ------------------ wcfsetup/install/lang/de.xml | 2 - wcfsetup/install/lang/en.xml | 2 - 6 files changed, 32 insertions(+), 104 deletions(-) delete mode 100644 wcfsetup/install/files/lib/system/worker/DatabaseConvertEncodingWorker.class.php diff --git a/com.woltlab.wcf/files_pre.tar b/com.woltlab.wcf/files_pre.tar index 94d3c22c987f6e66576a231cc02f1358dd9b0285..3dffecdd3ae27c236154987706cd7b85c4ad56d8 100644 GIT binary patch delta 1076 zcmZ{j%WoT16vpG0M?E}B!@E#87=x4II(D5$A-E76OfhL95keMKNv~(lWUexvN$%Xq zU{$Rv@v(-Tx2)K(LPCm!*sK zBp$-Ucm$8)6pC>07#_zHcoL`a6wY88PvaRpi|6n>Ucieuif-VhNYB0m%45--rtLViYpO?^sTSpCt$sB8v-|DIp))r}pR>{aK)jUw zAHzTld(6>&W`T3e&`#@g1^^-b!0x^a~<*Duw!+nt^DT4^Uu z*z6=WHfong_x|d3hqKF$Q#O2%YQybuYjRc5vnJ(bCku4QG*dPL)1q=>rO|zk?1jrd zTQ^uSMh#|WXX&O>l=hG7u2njkL$7k3TCEmU{PEAYVqCIscz36-WbsVp_7^u&>tE{k z=5JT3l$%_uv}G#F3Pa`kv2L;WpM1Uw69Ft1Z#i<^a-3uT2X`|1`d)W^xT={}1wHDi zXiwt7VJOqdQsc=hirs)B?FN=q>eGaX_Kt(1B`j6)G$#@~Oa8CF7>QUyTa&b;QIGSK zSz;q2_9SE?RVxXakg-70&7okH`_~!s381heU{S#4#~WI3>;*36i8p zlOaovJO$3V;F2OGt|)VjL}BAl!KI4khFk8qr$(Iz8a(pEGfi5w>F`3A-lzBW8?&X- vhH|uHSGDW7(vVVBw6YC33z?$ti@7%vzP0eCL4WwwoCyDQV7-f3(iGqSbWTWs diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 74a2caf60b..83c353b2af 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -504,12 +504,6 @@ - - com.woltlab.wcf.databaseConvertEncoding - com.woltlab.wcf.rebuildData - wcf\system\worker\DatabaseConvertEncodingWorker - -200 - com.woltlab.wcf.like com.woltlab.wcf.rebuildData @@ -1744,5 +1738,8 @@ com.woltlab.wcf.statDailyHandler + + com.woltlab.wcf.rebuildData + diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3_preUpdate.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3_preUpdate.php index bbcb970fc6..924bbcd81b 100644 --- a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3_preUpdate.php +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3_preUpdate.php @@ -3,7 +3,9 @@ namespace wcf\acp; use wcf\system\WCF; /** - * Checks for any duplicate usernames and aborts the upgrade if any are found. + * Checks for any duplicate usernames and aborts the upgrade if any are found. Afterwards a basic + * check is executed to validate if the database encoding was properly converted following an + * upgrade to WoltLab Suite 3.0. * * @author Alexander Ebert * @copyright 2001-2020 WoltLab GmbH @@ -29,3 +31,29 @@ if (!empty($usernames)) { throw new \RuntimeException(sprintf($message, implode(', ', $usernames))); } + +// Verify that the database encoding has been converted before upgrading to 5.3, since we removed this +// now obsolete worker with this version. +$sql = "SHOW FULL COLUMNS FROM wcf".WCF_N."_user_storage"; +$statement = WCF::getDB()->prepareStatement($sql); +$statement->execute(); + +$requireConversion = true; +while ($row = $statement->fetchArray()) { + if ($row['Field'] === 'field') { + if (preg_match('~^utf8mb4~', $row['Collation'])) { + $requireConversion = false; + } + } +} + +if ($requireConversion) { + if (WCF::getLanguage()->getFixedLanguageCode() === 'de') { + $message = "Die Datenbanktabellen wurden noch nicht auf utf8mb4 konvertiert, dies ist für das Upgrade unbedingt erforderlich."; + } + else { + $message = "The database tables have not yet been converted to utf8mb4, this is absolutely necessary for the upgrade"; + } + + throw new \RuntimeException($message); +} diff --git a/wcfsetup/install/files/lib/system/worker/DatabaseConvertEncodingWorker.class.php b/wcfsetup/install/files/lib/system/worker/DatabaseConvertEncodingWorker.class.php deleted file mode 100644 index c4ad4b9a12..0000000000 --- a/wcfsetup/install/files/lib/system/worker/DatabaseConvertEncodingWorker.class.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @package WoltLabSuite\Core\System\Worker - */ -class DatabaseConvertEncodingWorker extends AbstractRebuildDataWorker { - /** - * @inheritDoc - */ - protected $limit = 1; - - /** - * @inheritDoc - */ - public function initObjectList() { - // This rebuild worker has no database object list - // therefore we do nothing in this method an overwrite - // the parent method, that it does not throw an exception. - } - - /** - * @inheritDoc - */ - public function countObjects() { - if ($this->count === null) { - $this->count = count($this->getTables()); - } - } - - /** - * @inheritDoc - */ - public function getProceedURL() { - return LinkHandler::getInstance()->getLink('RebuildData'); - } - - /** - * @inheritDoc - */ - public function validate() { - WCF::getSession()->checkPermissions(['admin.management.canRebuildData']); - } - - /** - * @inheritDoc - */ - public function execute() { - $tables = $this->getTables(); - - $statement = WCF::getDB()->prepareStatement("SET FOREIGN_KEY_CHECKS=0"); - $statement->execute(); - - $convertTables = array_slice($tables, $this->limit * $this->loopCount, $this->limit); - foreach ($convertTables as $table) { - $sql = "ALTER TABLE " . $table . " CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - - $sql = "ALTER TABLE " . $table . " DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - } - - $statement = WCF::getDB()->prepareStatement("SET FOREIGN_KEY_CHECKS=1"); - $statement->execute(); - } - - /** - * Returns the list of known database tables. - * - * @return string[] - */ - protected function getTables() { - $sql = "SELECT DISTINCT sqlTable - FROM wcf".WCF_N."_package_installation_sql_log"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - $tables = []; - while ($table = $statement->fetchColumn()) { - $tables[] = $table; - } - - return $tables; - } -} diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index e2093080ca..d4c17f81e1 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -2635,8 +2635,6 @@ Kein Abschnitt darf leer sein und alle Abschnitten dürfen nur folgende Zeichen - - diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index aa3feaa28c..b58b985357 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -2562,8 +2562,6 @@ If you have already bought the licenses for the listed apps, th - - -- 2.20.1