1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Provide a setup warning about ft_min_word_len

Summary: Fixes T4130. Adds a setup warning when ft_min_word_len is set to the default value.

Test Plan: Hit setup warning; resovled setup warning. Searched for "DOS".

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4130

Differential Revision: https://secure.phabricator.com/D10259
This commit is contained in:
epriestley 2014-08-13 15:37:45 -07:00
parent ef0460c1ff
commit 5d62f56c8f

View file

@ -94,7 +94,8 @@ final class PhabricatorSetupCheckMySQL extends PhabricatorSetupCheck {
"%s\n". "%s\n".
"(You can also use a different file if you prefer. The file ". "(You can also use a different file if you prefer. The file ".
"suggested above has about 50 of the most common English words.)\n\n". "suggested above has about 50 of the most common English words.)\n\n".
"Finally, run this command:\n\n". "Finally, run this command to rebuild indexes using the new ".
"rules:\n\n".
"%s", "%s",
phutil_tag('tt', array(), 'my.cnf'), phutil_tag('tt', array(), 'my.cnf'),
phutil_tag('tt', array(), '[mysqld]'), phutil_tag('tt', array(), '[mysqld]'),
@ -111,6 +112,53 @@ final class PhabricatorSetupCheckMySQL extends PhabricatorSetupCheck {
->setMessage($message); ->setMessage($message);
} }
} }
$min_len = queryfx_one($conn_raw, 'SELECT @@ft_min_word_len');
$min_len = $min_len['@@ft_min_word_len'];
if ($min_len == 4) {
if (!PhabricatorDefaultSearchEngineSelector::shouldUseElasticSearch()) {
$namespace = PhabricatorEnv::getEnvConfig('storage.default-namespace');
$summary = pht(
'MySQL is configured to only index words with at least 4 '.
'characters.');
$message = pht(
"Your MySQL instance is configured to use the default minimum word ".
"length when building search indexes, which is 4. This means words ".
"which are only 3 characters long will not be indexed and can not ".
"be searched for.\n\n".
"For example, you will not be able to find search results for words ".
"like 'SMS', 'web', or 'DOS'.\n\n".
"You can change this setting to 3 to allow these words to be ".
"indexed. Alternatively, you can ignore this warning if you are ".
"not concerned about searching for 3-letter words. If you later ".
"plan to configure ElasticSearch, you can also ignore this warning: ".
"only MySQL fulltext search is affected.\n\n".
"To reduce the minimum word length to 3, add this to your %s file ".
"(in the %s section) and then restart %s:\n\n".
"%s\n".
"Finally, run this command to rebuild indexes using the new ".
"rules:\n\n".
"%s",
phutil_tag('tt', array(), 'my.cnf'),
phutil_tag('tt', array(), '[mysqld]'),
phutil_tag('tt', array(), 'mysqld'),
phutil_tag('pre', array(), 'ft_min_word_len=3'),
phutil_tag(
'pre',
array(),
"mysql> REPAIR TABLE {$namespace}_search.search_documentfield;"));
$this->newIssue('mysql.ft_min_word_len')
->setName(pht('MySQL is Using Default Minimum Word Length'))
->setSummary($summary)
->setMessage($message);
}
}
} }
} }