Add system check for search storage engines
authorJoshua Rüsweg <ruesweg@woltlab.com>
Thu, 1 Aug 2019 14:16:45 +0000 (16:16 +0200)
committerJoshua Rüsweg <ruesweg@woltlab.com>
Thu, 1 Aug 2019 14:18:44 +0000 (16:18 +0200)
See #2977

wcfsetup/install/files/acp/templates/systemCheck.tpl
wcfsetup/install/files/lib/acp/page/SystemCheckPage.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index ec5e5d4b662f21949c1f1998bfa9822fcba83772..15e8e5a3b260c9c4165dc4a8afbf6ebcfcaede38 100644 (file)
                        <small>{lang}wcf.acp.systemCheck.mysql.foreignKeys.description{/lang}</small>
                </dd>
        </dl>
+       
+       <dl{if !$results[mysql][searchEngine][result]} class="formError"{/if}>
+               <dt>{lang}wcf.acp.systemCheck.mysql.searchEngine{/lang}</dt>
+               <dd>
+                       {if $results[mysql][searchEngine][result]}
+                               {@$statusOk} {lang}wcf.acp.systemCheck.pass{/lang}
+                       {else}
+                               {@$statusInsufficient} {lang}wcf.acp.systemCheck.mysql.searchEngine.incorrect{/lang}
+                       {/if}
+                       <small>{lang}wcf.acp.systemCheck.mysql.searchEngine.description{/lang}</small>
+               </dd>
+       </dl>
 </section>
 
 <section class="section">
index 2f8570b0e82c97892d45af8227d612c4af447a61..cf1f535beecdba048d2730f57bc16401f08476d0 100644 (file)
@@ -1,9 +1,11 @@
 <?php
 namespace wcf\acp\page;
 use wcf\data\application\Application;
+use wcf\data\object\type\ObjectTypeCache;
 use wcf\page\AbstractPage;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\exception\SystemException;
+use wcf\system\search\SearchIndexManager;
 use wcf\system\WCF;
 use wcf\util\FileUtil;
 
@@ -121,6 +123,10 @@ class SystemCheckPage extends AbstractPage {
                        'result' => 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;
                }
        }
index 37d3f301578b39b6d7c8a19c93027a2a8ce60c73..36344359e85a5cfcf7b00c4889ebf13025d08f2f 100644 (file)
@@ -2707,6 +2707,9 @@ Kein Abschnitt darf leer sein und alle Abschnitten dürfen nur folgende Zeichen
                <item name="wcf.acp.systemCheck.mysql.version.description"><![CDATA[Es wird mindestens MySQL {$mysqlVersions[mysql]} bzw. MariaDB {$mysqlVersions[mariadb][5]} oder MariaDB {$mysqlVersions[mariadb][10]} benötigt, grundsätzlich wird der Einsatz neuerer Version ausdrücklich empfohlen.]]></item>
                <item name="wcf.acp.systemCheck.mysql.foreignKeys"><![CDATA[Fremdschlüssel]]></item>
                <item name="wcf.acp.systemCheck.mysql.foreignKeys.description"><![CDATA[Fremdschlüssel werden mit der Installation in der Datenbank angelegt und werden für einen einwandfreien Betrieb benötigt.]]></item>
+               <item name="wcf.acp.systemCheck.mysql.searchEngine"><![CDATA[Suche]]></item>
+               <item name="wcf.acp.systemCheck.mysql.searchEngine.description"><![CDATA[Alle Tabellen, die für die Suche genutzt werden, müssen mit der Storage-Engine MyISAM betrieben werden.]]></item>
+               <item name="wcf.acp.systemCheck.mysql.searchEngine.incorrect"><![CDATA[Die folgenden Tabellen verwenden eine inkorrekte Storage-Engine (erwartete Storage-Engine: <code>MyISAM</code>): {implode from=$results[mysql][searchEngine][incorrectTables] key=tableName item=engine glue=", "}<code>{$tableName}</code> (<code>{$engine}</code>){/implode}.]]></item>
                <item name="wcf.acp.systemCheck.php.extension"><![CDATA[Erweiterungen]]></item>
                <item name="wcf.acp.systemCheck.php.extension.description"><![CDATA[Die offiziellen Erweiterungen von PHP stellen zusätzliche Funktionen bereit, die für den Betrieb der Software notwendig sind.]]></item>
                <item name="wcf.acp.systemCheck.php.memoryLimit"><![CDATA[Verfügbarer Arbeitsspeicher („memory_limit“)]]></item>
index 825c194f811a2fc58997c585676a7342e0bc532e..c57cee31155548d42fbd30768e66544d6a96da58 100644 (file)
@@ -2635,6 +2635,9 @@ If you have <strong>already bought the licenses for the listed apps</strong>, th
                <item name="wcf.acp.systemCheck.mysql.version.description"><![CDATA[MySQL {$mysqlVersions[mysql]} or MariaDB {$mysqlVersions[mariadb][5]} or MariaDB {$mysqlVersions[mariadb][10]} are required at minimum, but it’s strongly recommended to always use the latest available version.]]></item>
                <item name="wcf.acp.systemCheck.mysql.foreignKeys"><![CDATA[Foreign Keys]]></item>
                <item name="wcf.acp.systemCheck.mysql.foreignKeys.description"><![CDATA[Foreign Keys are created with the installation and are required for the software to work.]]></item>
+               <item name="wcf.acp.systemCheck.mysql.searchEngine"><![CDATA[Search]]></item>
+               <item name="wcf.acp.systemCheck.mysql.searchEngine.description"><![CDATA[All tables used for the search must be configured with the MyISAM storage engine.]]></item>
+               <item name="wcf.acp.systemCheck.mysql.searchEngine.incorrect"><![CDATA[The following tables using an incorrect storage engine (expected storage engine <code>MyISAM</code>): {implode from=$results[mysql][searchEngine][incorrectTables] key=tableName item=engine glue=", "}<code>{$tableName}</code> (<code>{$engine}</code>){/implode}.]]></item>
                <item name="wcf.acp.systemCheck.php.extension"><![CDATA[Extensions]]></item>
                <item name="wcf.acp.systemCheck.php.extension.description"><![CDATA[The official PHP extensions provide additional capabilities and features that are required for the software to work.]]></item>
                <item name="wcf.acp.systemCheck.php.memoryLimit"><![CDATA[Available Memory (“memory_limit”)]]></item>