Add SearchEngineConvertInnoDbWorker
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 23 Dec 2020 12:01:17 +0000 (13:01 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 23 Dec 2020 12:01:17 +0000 (13:01 +0100)
com.woltlab.wcf/objectType.xml
wcfsetup/install/files/lib/system/worker/SearchEngineConvertInnoDbWorker.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 2b70815363f986547b007df06fa61e5a67c4108a..59bb5ad52c5a2aab59da787711b5ad9c4a048cd8 100644 (file)
                </type>
                <!-- /importers -->
                <!-- rebuild data workers -->
+               <type>
+                       <name>com.woltlab.wcf.searchEngineConvertInnoDb</name>
+                       <definitionname>com.woltlab.wcf.rebuildData</definitionname>
+                       <classname>wcf\system\worker\SearchEngineConvertInnoDbWorker</classname>
+                       <nicevalue>-200</nicevalue>
+               </type>
                <type>
                        <name>com.woltlab.wcf.like</name>
                        <definitionname>com.woltlab.wcf.rebuildData</definitionname>
diff --git a/wcfsetup/install/files/lib/system/worker/SearchEngineConvertInnoDbWorker.class.php b/wcfsetup/install/files/lib/system/worker/SearchEngineConvertInnoDbWorker.class.php
new file mode 100644 (file)
index 0000000..7d4ec5f
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+namespace wcf\system\worker;
+use wcf\data\object\type\ObjectTypeCache;
+use wcf\system\request\LinkHandler;
+use wcf\system\search\SearchIndexManager;
+use wcf\system\WCF;
+
+/**
+ * Worker implementation for search table engine conversion.
+ * 
+ * @author     Tim Duesterhus, Alexander Ebert
+ * @copyright  2001-2020 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Worker
+ */
+class SearchEngineConvertInnoDbWorker 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();
+               
+               $sql = "SELECT          LOWER(ENGINE)
+                       FROM            INFORMATION_SCHEMA.TABLES
+                       WHERE           TABLE_NAME = ?
+                               AND     TABLE_SCHEMA = ?";
+               $checkStatement = WCF::getDB()->prepareStatement($sql);
+               
+               $convertTables = array_slice($tables, $this->limit * $this->loopCount, $this->limit);
+               foreach ($convertTables as $table) {
+                       $checkStatement->execute([
+                               $table,
+                               WCF::getDB()->getDatabaseName(),
+                       ]);
+                       if ($checkStatement->fetchSingleColumn() !== 'innodb') {
+                               $sql = "ALTER TABLE " . $table . " ENGINE = InnoDB";
+                               $statement = WCF::getDB()->prepareStatement($sql);
+                               $statement->execute();
+                       }
+               }
+       }
+       
+       /**
+        * Returns the list of known database tables.
+        * 
+        * @return      string[]
+        */
+       protected function getTables() {
+               $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.searchableObjectType');
+               $tableNames = [];
+               foreach ($objectTypes as $objectType) {
+                       $tableNames[] = SearchIndexManager::getTableName($objectType->objectType);
+               }
+               
+               return $tableNames;
+       }
+}
index 7ad6aa850fea7ff605d2452e5a42e1104b62df2b..03938864165f266707697644616c5a0401e9dad2 100644 (file)
@@ -2645,6 +2645,8 @@ Kein Abschnitt darf leer sein und alle Abschnitten dürfen nur folgende Zeichen
                <item name="wcf.acp.rebuildData.com.woltlab.wcf.activityPointEvent.description"><![CDATA[Berechnet Punkte pro Aktivität neu]]></item>
                <item name="wcf.acp.rebuildData.com.woltlab.wcf.activityPointItems"><![CDATA[Punkte-Aktivitäten aktualisieren]]></item>
                <item name="wcf.acp.rebuildData.com.woltlab.wcf.activityPointItems.description"><![CDATA[Berechnet Anzahl an Aktivitäten neu, für die Benutzer Punkte erhalten; aktualisiert Benutzerränge]]></item>
+               <item name="wcf.acp.rebuildData.com.woltlab.wcf.searchEngineConvertInnoDb.description"><![CDATA[Stellt die Tabellen des Suchindex auf die InnoDB-Engine um.]]></item>
+               <item name="wcf.acp.rebuildData.com.woltlab.wcf.searchEngineConvertInnoDb"><![CDATA[Suchindex auf InnoDB umstellen]]></item>
        </category>
        <category name="wcf.acp.rescueMode">
                <item name="wcf.acp.rescueMode"><![CDATA[Systemwiederherstellung]]></item>
index 72f42ff92aae93e5504273b640011fb9e8622856..3585fb9a30a74aed089ec2ce8cb871f351d6d79a 100644 (file)
@@ -2573,6 +2573,8 @@ If you have <strong>already bought the licenses for the listed apps</strong>, th
                <item name="wcf.acp.rebuildData.com.woltlab.wcf.activityPointEvent.description"><![CDATA[Recalculates points per activity.]]></item>
                <item name="wcf.acp.rebuildData.com.woltlab.wcf.activityPointItems"><![CDATA[Rebuilds Point Activities]]></item>
                <item name="wcf.acp.rebuildData.com.woltlab.wcf.activityPointItems.description"><![CDATA[Recalculates the number of activities for which users get points and rebuilds user ranks.]]></item>
+               <item name="wcf.acp.rebuildData.com.woltlab.wcf.searchEngineConvertInnoDb.description"><![CDATA[Migrates the search engine tables to the InnoDB storage engine.]]></item>
+               <item name="wcf.acp.rebuildData.com.woltlab.wcf.searchEngineConvertInnoDb"><![CDATA[Migrate Search Index to InnoDB]]></item>
        </category>
        <category name="wcf.acp.rescueMode">
                <item name="wcf.acp.rescueMode"><![CDATA[Rescue Mode]]></item>