Page MenuHomePhabricator

D18499.id44445.diff
No OneTemporary

D18499.id44445.diff

diff --git a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php
--- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php
+++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php
@@ -232,9 +232,24 @@
}
if (strlen($map['ferret'])) {
+ $raw_query = $map['ferret'];
+
+ $compiler = id(new PhutilSearchQueryCompiler())
+ ->setEnableFunctions(true);
+
+ $raw_tokens = $compiler->newTokens($raw_query);
+
+ $fulltext_tokens = array();
+ foreach ($raw_tokens as $raw_token) {
+ $fulltext_token = id(new PhabricatorFulltextToken())
+ ->setToken($raw_token);
+
+ $fulltext_tokens[] = $fulltext_token;
+ }
+
$query->withFerretConstraint(
id(new ManiphestTask())->newFerretEngine(),
- $map['ferret']);
+ $fulltext_tokens);
}
if ($map['parentIDs']) {
diff --git a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
--- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
+++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
@@ -28,7 +28,7 @@
private $spaceIsArchived;
private $ngrams = array();
private $ferretEngine;
- private $ferretConstraints;
+ private $ferretTokens;
protected function getPageCursors(array $page) {
return array(
@@ -1386,7 +1386,7 @@
public function withFerretConstraint(
PhabricatorFerretEngine $engine,
- $raw_query) {
+ array $fulltext_tokens) {
if ($this->ferretEngine) {
throw new Exception(
@@ -1394,12 +1394,12 @@
'Query may not have multiple fulltext constraints.'));
}
- if (!strlen($raw_query)) {
+ if (!$fulltext_tokens) {
return $this;
}
$this->ferretEngine = $engine;
- $this->ferretConstraints = preg_split('/\s+/', $raw_query);
+ $this->ferretTokens = $fulltext_tokens;
return $this;
}
@@ -1416,9 +1416,11 @@
$ngram_table_name = $ngram_table->getTableName();
$flat = array();
- foreach ($this->ferretConstraints as $term) {
- $value = $term;
- $length = count(phutil_utf8v($term));
+ foreach ($this->ferretTokens as $fulltext_token) {
+ $raw_token = $fulltext_token->getToken();
+ $value = $raw_token->getValue();
+
+ $length = count(phutil_utf8v($value));
if ($length >= 3) {
$ngrams = $ngram_engine->getNgramsFromString($value, 'query');
@@ -1509,19 +1511,22 @@
}
$where = array();
- foreach ($this->ferretConstraints as $constraint) {
+ foreach ($this->ferretTokens as $fulltext_token) {
+ $raw_token = $fulltext_token->getToken();
+ $value = $raw_token->getValue();
+
$where[] = qsprintf(
$conn,
'(ftfield.rawCorpus LIKE %~ OR ftfield.normalCorpus LIKE %~)',
- $constraint,
- $constraint);
+ $value,
+ $value);
}
return $where;
}
protected function shouldGroupFerretResultRows() {
- return (bool)$this->ferretConstraints;
+ return (bool)$this->ferretTokens;
}

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 19, 6:31 PM (4 d, 12 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7721851
Default Alt Text
D18499.id44445.diff (3 KB)

Event Timeline