@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Provide a setup warning about using the default MySQL stopword file

Summary:
Fixes T2605.

- Add a setup warning about the stopword file.
- Provide a simpler stopword file.

Test Plan:
- Hit setup warning.
- Resolved it according to instructions.
- Added "various" to a task, then searched for it, found the task.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2605

Differential Revision: https://secure.phabricator.com/D10258

+109 -2
+50
resources/sql/stopwords.txt
··· 1 + the 2 + be 3 + and 4 + of 5 + a 6 + in 7 + to 8 + have 9 + to 10 + it 11 + I 12 + that 13 + for 14 + you 15 + he 16 + with 17 + on 18 + do 19 + say 20 + this 21 + they 22 + at 23 + but 24 + we 25 + his 26 + from 27 + that 28 + not 29 + by 30 + or 31 + as 32 + what 33 + go 34 + their 35 + can 36 + who 37 + get 38 + if 39 + would 40 + all 41 + my 42 + will 43 + as 44 + up 45 + there 46 + so 47 + its 48 + us 49 + in 50 + on
+52
src/applications/config/check/PhabricatorSetupCheckMySQL.php
··· 59 59 ->setSummary($summary) 60 60 ->setMessage($message); 61 61 } 62 + 63 + $stopword_file = queryfx_one($conn_raw, 'SELECT @@ft_stopword_file'); 64 + $stopword_file = $stopword_file['@@ft_stopword_file']; 65 + if ($stopword_file == '(built-in)') { 66 + if (!PhabricatorDefaultSearchEngineSelector::shouldUseElasticSearch()) { 67 + 68 + $root = dirname(phutil_get_library_root('phabricator')); 69 + $stopword_path = $root.'/resources/sql/stopwords.txt'; 70 + $stopword_path = Filesystem::resolvePath($stopword_path); 71 + 72 + $namespace = PhabricatorEnv::getEnvConfig('storage.default-namespace'); 73 + 74 + $summary = pht( 75 + 'MySQL is using a default stopword file, which will prevent '. 76 + 'searching for many common words.'); 77 + 78 + $message = pht( 79 + "Your MySQL instance is using the builtin stopword file for ". 80 + "building search indexes. This can make Phabricator's search ". 81 + "feature less useful.\n\n". 82 + "Stopwords are common words which are not indexed and thus can not ". 83 + "be searched for. The default stopword file has about 500 words, ". 84 + "including various words which you are likely to wish to search ". 85 + "for, such as 'various', 'likely', 'wish', and 'zero'.\n\n". 86 + "To make search more useful, you can use an alternate stopword ". 87 + "file with fewer words. Alternatively, if you aren't concerned ". 88 + "about searching for common words, you can ignore this warning. ". 89 + "If you later plan to configure ElasticSearch, you can also ignore ". 90 + "this warning: this stopword file only affects MySQL fulltext ". 91 + "indexes.\n\n". 92 + "To choose a different stopword file, add this to your %s file ". 93 + "(in the %s section) and then restart %s:\n\n". 94 + "%s\n". 95 + "(You can also use a different file if you prefer. The file ". 96 + "suggested above has about 50 of the most common English words.)\n\n". 97 + "Finally, run this command:\n\n". 98 + "%s", 99 + phutil_tag('tt', array(), 'my.cnf'), 100 + phutil_tag('tt', array(), '[mysqld]'), 101 + phutil_tag('tt', array(), 'mysqld'), 102 + phutil_tag('pre', array(), 'ft_stopword_file='.$stopword_path), 103 + phutil_tag( 104 + 'pre', 105 + array(), 106 + "mysql> REPAIR TABLE {$namespace}_search.search_documentfield;")); 107 + 108 + $this->newIssue('mysql.ft_stopword_file') 109 + ->setName(pht('MySQL is Using Default Stopword File')) 110 + ->setSummary($summary) 111 + ->setMessage($message); 112 + } 113 + } 62 114 } 63 115 64 116 }
+7 -2
src/applications/search/selector/PhabricatorDefaultSearchEngineSelector.php
··· 4 4 extends PhabricatorSearchEngineSelector { 5 5 6 6 public function newEngine() { 7 - $elastic_host = PhabricatorEnv::getEnvConfig('search.elastic.host'); 8 - if ($elastic_host) { 7 + if (self::shouldUseElasticSearch()) { 8 + $elastic_host = PhabricatorEnv::getEnvConfig('search.elastic.host'); 9 9 $elastic_index = PhabricatorEnv::getEnvConfig('search.elastic.namespace'); 10 10 return new PhabricatorSearchEngineElastic($elastic_host, $elastic_index); 11 11 } 12 12 return new PhabricatorSearchEngineMySQL(); 13 13 } 14 + 15 + public static function shouldUseElasticSearch() { 16 + return (bool)PhabricatorEnv::getEnvConfig('search.elastic.host'); 17 + } 18 + 14 19 }