From: Tim Düsterhus Date: Wed, 23 Dec 2020 12:01:17 +0000 (+0100) Subject: Add SearchEngineConvertInnoDbWorker X-Git-Tag: 5.4.0_Alpha_1~509^2^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6e969ec63aa58d66e5e899d8ed851ea22e024563;p=GitHub%2FWoltLab%2FWCF.git Add SearchEngineConvertInnoDbWorker --- diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 2b70815363..59bb5ad52c 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -504,6 +504,12 @@ + + com.woltlab.wcf.searchEngineConvertInnoDb + com.woltlab.wcf.rebuildData + wcf\system\worker\SearchEngineConvertInnoDbWorker + -200 + com.woltlab.wcf.like com.woltlab.wcf.rebuildData 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 index 0000000000..7d4ec5fe5a --- /dev/null +++ b/wcfsetup/install/files/lib/system/worker/SearchEngineConvertInnoDbWorker.class.php @@ -0,0 +1,94 @@ + + * @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; + } +} diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 7ad6aa850f..0393886416 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -2645,6 +2645,8 @@ 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 72f42ff92a..3585fb9a30 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -2573,6 +2573,8 @@ If you have already bought the licenses for the listed apps, th + +