Page MenuHomePhabricator

D16939.id40772.diff
No OneTemporary

D16939.id40772.diff

diff --git a/src/applications/config/check/PhabricatorMySQLSetupCheck.php b/src/applications/config/check/PhabricatorMySQLSetupCheck.php
--- a/src/applications/config/check/PhabricatorMySQLSetupCheck.php
+++ b/src/applications/config/check/PhabricatorMySQLSetupCheck.php
@@ -248,44 +248,6 @@
}
}
- $bool_syntax = $ref->loadRawMySQLConfigValue('ft_boolean_syntax');
- if ($bool_syntax != ' |-><()~*:""&^') {
- if ($this->shouldUseMySQLSearchEngine()) {
- $summary = pht(
- 'MySQL (on host "%s") is configured to search on fulltext indexes '.
- 'using "OR" by default. Using "AND" is usually the desired '.
- 'behaviour.',
- $host_name);
-
- $message = pht(
- "Database host \"%s\" is configured to use the default Boolean ".
- "search syntax when using fulltext indexes. This means searching ".
- "for 'search words' will yield the query 'search OR words' ".
- "instead of the desired 'search AND words'.\n\n".
- "This might produce unexpected search results. \n\n".
- "You can change this setting to a more sensible default. ".
- "Alternatively, you can ignore this warning if ".
- "using 'OR' is the desired behaviour. If you later plan ".
- "to configure ElasticSearch, you can also ignore this warning: ".
- "only MySQL fulltext search is affected.\n\n".
- "To change this setting, add this to your %s file ".
- "(in the %s section) and then restart %s:\n\n".
- "%s\n",
- $host_name,
- phutil_tag('tt', array(), 'my.cnf'),
- phutil_tag('tt', array(), '[mysqld]'),
- phutil_tag('tt', array(), 'mysqld'),
- phutil_tag('pre', array(), 'ft_boolean_syntax=\' |-><()~*:""&^\''));
-
- $this->newIssue('mysql.ft_boolean_syntax')
- ->setName(pht('MySQL is Using the Default Boolean Syntax'))
- ->setSummary($summary)
- ->setMessage($message)
- ->setDatabaseRef($ref)
- ->addMySQLConfig('ft_boolean_syntax');
- }
- }
-
$innodb_pool = $ref->loadRawMySQLConfigValue('innodb_buffer_pool_size');
$innodb_bytes = phutil_parse_bytes($innodb_pool);
$innodb_readable = phutil_format_bytes($innodb_bytes);
diff --git a/src/applications/conpherence/query/ConpherenceFulltextQuery.php b/src/applications/conpherence/query/ConpherenceFulltextQuery.php
--- a/src/applications/conpherence/query/ConpherenceFulltextQuery.php
+++ b/src/applications/conpherence/query/ConpherenceFulltextQuery.php
@@ -56,10 +56,14 @@
}
if (strlen($this->fulltext)) {
+ $compiled_query = PhabricatorSearchDocument::newQueryCompiler()
+ ->setQuery($this->fulltext)
+ ->compileQuery();
+
$where[] = qsprintf(
$conn_r,
'MATCH(i.corpus) AGAINST (%s IN BOOLEAN MODE)',
- $this->fulltext);
+ $compiled_query);
}
return $this->formatWhereClause($where);
diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php
--- a/src/applications/search/controller/PhabricatorApplicationSearchController.php
+++ b/src/applications/search/controller/PhabricatorApplicationSearchController.php
@@ -317,6 +317,8 @@
$exec_errors[] = pht(
'This query specifies an invalid parameter. Review the '.
'query parameters and correct errors.');
+ } catch (PhutilSearchQueryCompilerSyntaxException $ex) {
+ $exec_errors[] = $ex->getMessage();
}
// The engine may have encountered additional errors during rendering;
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
@@ -165,7 +165,8 @@
$conn_r = $dao_doc->establishConnection('r');
- $q = $query->getParameter('query');
+ $raw_query = $query->getParameter('query');
+ $q = $this->compileQuery($raw_query);
if (strlen($q)) {
$join[] = qsprintf(
@@ -351,6 +352,14 @@
return $sql;
}
+ private function compileQuery($raw_query) {
+ $compiler = PhabricatorSearchDocument::newQueryCompiler();
+
+ return $compiler
+ ->setQuery($raw_query)
+ ->compileQuery();
+ }
+
public function indexExists() {
return true;
}
diff --git a/src/applications/search/storage/document/PhabricatorSearchDocument.php b/src/applications/search/storage/document/PhabricatorSearchDocument.php
--- a/src/applications/search/storage/document/PhabricatorSearchDocument.php
+++ b/src/applications/search/storage/document/PhabricatorSearchDocument.php
@@ -37,4 +37,20 @@
return 'phid';
}
+ public static function newQueryCompiler() {
+ $table = new self();
+ $conn = $table->establishConnection('r');
+
+ $compiler = new PhutilSearchQueryCompiler();
+
+ $operators = queryfx_one(
+ $conn,
+ 'SELECT @@ft_boolean_syntax AS syntax');
+ if ($operators) {
+ $compiler->setOperators($operators['syntax']);
+ }
+
+ return $compiler;
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 3:19 AM (21 h, 31 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6909310
Default Alt Text
D16939.id40772.diff (5 KB)

Event Timeline