From 9bab940f90707088820a15962c1a01f9a3b5e9b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Thu, 1 Aug 2019 16:16:45 +0200 Subject: [PATCH] Add system check for search storage engines See #2977 --- .../files/acp/templates/systemCheck.tpl | 12 +++++++ .../lib/acp/page/SystemCheckPage.class.php | 32 ++++++++++++++++++- wcfsetup/install/lang/de.xml | 3 ++ wcfsetup/install/lang/en.xml | 3 ++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/acp/templates/systemCheck.tpl b/wcfsetup/install/files/acp/templates/systemCheck.tpl index ec5e5d4b66..15e8e5a3b2 100644 --- a/wcfsetup/install/files/acp/templates/systemCheck.tpl +++ b/wcfsetup/install/files/acp/templates/systemCheck.tpl @@ -141,6 +141,18 @@ {lang}wcf.acp.systemCheck.mysql.foreignKeys.description{/lang} + + +
{lang}wcf.acp.systemCheck.mysql.searchEngine{/lang}
+
+ {if $results[mysql][searchEngine][result]} + {@$statusOk} {lang}wcf.acp.systemCheck.pass{/lang} + {else} + {@$statusInsufficient} {lang}wcf.acp.systemCheck.mysql.searchEngine.incorrect{/lang} + {/if} + {lang}wcf.acp.systemCheck.mysql.searchEngine.description{/lang} +
+
diff --git a/wcfsetup/install/files/lib/acp/page/SystemCheckPage.class.php b/wcfsetup/install/files/lib/acp/page/SystemCheckPage.class.php index 2f8570b0e8..cf1f535bee 100644 --- a/wcfsetup/install/files/lib/acp/page/SystemCheckPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/SystemCheckPage.class.php @@ -1,9 +1,11 @@ false, 'version' => '0.0.0', 'foreignKeys' => false, + 'searchEngine' => [ + 'result' => false, + 'incorrectTables' => [] + ], ], 'php' => [ 'extension' => [], @@ -245,7 +251,31 @@ class SystemCheckPage extends AbstractPage { $this->results['mysql']['foreignKeys'] = $statement->fetchSingleColumn() === $expectedForeignKeyCount; - if ($this->results['mysql']['result'] && $this->results['mysql']['innodb'] && $this->results['mysql']['foreignKeys']) { + // check search engine tables + $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.searchableObjectType'); + $tableNames = []; + foreach ($objectTypes as $objectType) { + $tableNames[] = SearchIndexManager::getTableName($objectType->objectType); + } + $conditionBuilder = new PreparedStatementConditionBuilder(true); + $conditionBuilder->add('TABLE_NAME IN (?)', [$tableNames]); + $conditionBuilder->add('TABLE_SCHEMA = ?', [WCF::getDB()->getDatabaseName()]); + + $sql = "SELECT TABLE_NAME, ENGINE + FROM INFORMATION_SCHEMA.TABLES + ". $conditionBuilder; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($conditionBuilder->getParameters()); + + while ($row = $statement->fetchArray()) { + if ($row['ENGINE'] !== 'MyISAM') { + $this->results['mysql']['searchEngine']['incorrectTables'][$row['TABLE_NAME']] = $row['ENGINE']; + } + } + + $this->results['mysql']['searchEngine']['result'] = empty($this->results['mysql']['searchEngine']['incorrectTables']); + + if ($this->results['mysql']['result'] && $this->results['mysql']['innodb'] && $this->results['mysql']['foreignKeys'] && $this->results['mysql']['searchEngine']['result']) { $this->results['status']['mysql'] = true; } } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 37d3f30157..36344359e8 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -2707,6 +2707,9 @@ Kein Abschnitt darf leer sein und alle Abschnitten dürfen nur folgende Zeichen + + + MyISAM): {implode from=$results[mysql][searchEngine][incorrectTables] key=tableName item=engine glue=", "}{$tableName} ({$engine}){/implode}.]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 825c194f81..c57cee3115 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -2635,6 +2635,9 @@ If you have already bought the licenses for the listed apps, th + + + MyISAM): {implode from=$results[mysql][searchEngine][incorrectTables] key=tableName item=engine glue=", "}{$tableName} ({$engine}){/implode}.]]> -- 2.20.1