Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15284018
D17673.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D17673.diff
View Options
diff --git a/src/applications/search/fulltextstorage/PhabricatorMySQLFulltextStorageEngine.php b/src/applications/search/fulltextstorage/PhabricatorMySQLFulltextStorageEngine.php
--- a/src/applications/search/fulltextstorage/PhabricatorMySQLFulltextStorageEngine.php
+++ b/src/applications/search/fulltextstorage/PhabricatorMySQLFulltextStorageEngine.php
@@ -473,43 +473,56 @@
}
private function newEngineLimits(AphrontDatabaseConnection $conn) {
- $result = queryfx_one(
- $conn,
- 'SELECT
- @@innodb_ft_min_token_size innodb_max,
- @@ft_min_word_len myisam_max,
- @@ft_stopword_file myisam_stopwords');
+ // First, try InnoDB. Some database may not have both table engines, so
+ // selecting variables from missing table engines can fail and throw.
- if ($result['innodb_max']) {
+ try {
+ $result = queryfx_one(
+ $conn,
+ 'SELECT @@innodb_ft_min_token_size innodb_max');
+ } catch (AphrontQueryException $ex) {
+ $result = null;
+ }
+
+ if ($result) {
$min_len = $result['innodb_max'];
$stopwords = queryfx_all(
$conn,
'SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DEFAULT_STOPWORD');
$stopwords = ipull($stopwords, 'value');
$stopwords = array_fuse($stopwords);
- } else {
- $min_len = $result['myisam_max'];
-
- $file = $result['myisam_stopwords'];
- if (preg_match('(/resources/sql/stopwords\.txt\z)', $file)) {
- // If this is set to something that looks like the Phabricator
- // stopword file, read that.
- $file = 'stopwords.txt';
- } else {
- // Otherwise, just use the default stopwords. This might be wrong
- // but we can't read the actual value dynamically and reading
- // whatever file the variable is set to could be a big headache
- // to get right from a security perspective.
- $file = 'stopwords_myisam.txt';
- }
- $root = dirname(phutil_get_library_root('phabricator'));
- $data = Filesystem::readFile($root.'/resources/sql/'.$file);
- $stopwords = explode("\n", $data);
- $stopwords = array_filter($stopwords);
- $stopwords = array_fuse($stopwords);
+ return array($min_len, $stopwords);
}
+ // If InnoDB fails, try MyISAM.
+ $result = queryfx_one(
+ $conn,
+ 'SELECT
+ @@ft_min_word_len myisam_max,
+ @@ft_stopword_file myisam_stopwords');
+
+ $min_len = $result['myisam_max'];
+
+ $file = $result['myisam_stopwords'];
+ if (preg_match('(/resources/sql/stopwords\.txt\z)', $file)) {
+ // If this is set to something that looks like the Phabricator
+ // stopword file, read that.
+ $file = 'stopwords.txt';
+ } else {
+ // Otherwise, just use the default stopwords. This might be wrong
+ // but we can't read the actual value dynamically and reading
+ // whatever file the variable is set to could be a big headache
+ // to get right from a security perspective.
+ $file = 'stopwords_myisam.txt';
+ }
+
+ $root = dirname(phutil_get_library_root('phabricator'));
+ $data = Filesystem::readFile($root.'/resources/sql/'.$file);
+ $stopwords = explode("\n", $data);
+ $stopwords = array_filter($stopwords);
+ $stopwords = array_fuse($stopwords);
+
return array($min_len, $stopwords);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 5, 9:04 AM (4 d, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7224435
Default Alt Text
D17673.diff (3 KB)
Attached To
Mode
D17673: Fix a fulltext search issue where finding token length and stopwords could fail
Attached
Detach File
Event Timeline
Log In to Comment