Differential D18536 Diff 44514 src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
Show First 20 Lines • Show All 1,396 Lines • ▼ Show 20 Lines | public function withFerretConstraint( | ||||
if (!$fulltext_tokens) { | if (!$fulltext_tokens) { | ||||
return $this; | return $this; | ||||
} | } | ||||
$this->ferretEngine = $engine; | $this->ferretEngine = $engine; | ||||
$this->ferretTokens = $fulltext_tokens; | $this->ferretTokens = $fulltext_tokens; | ||||
$current_function = $engine->getDefaultFunctionKey(); | |||||
$function_map = array( | |||||
'all' => PhabricatorSearchDocumentFieldType::FIELD_ALL, | |||||
'title' => PhabricatorSearchDocumentFieldType::FIELD_TITLE, | |||||
'body' => PhabricatorSearchDocumentFieldType::FIELD_BODY, | |||||
'core' => PhabricatorSearchDocumentFieldType::FIELD_CORE, | |||||
); | |||||
$current_function = 'all'; | |||||
$table_map = array(); | $table_map = array(); | ||||
$idx = 1; | $idx = 1; | ||||
foreach ($this->ferretTokens as $fulltext_token) { | foreach ($this->ferretTokens as $fulltext_token) { | ||||
$raw_token = $fulltext_token->getToken(); | $raw_token = $fulltext_token->getToken(); | ||||
$function = $raw_token->getFunction(); | $function = $raw_token->getFunction(); | ||||
if ($function === null) { | if ($function === null) { | ||||
$function = $current_function; | $function = $current_function; | ||||
} | } | ||||
if (!isset($function_map[$function])) { | $raw_field = $engine->getFieldForFunction($function); | ||||
throw new PhutilSearchQueryCompilerSyntaxException( | |||||
pht( | |||||
'Unknown search function "%s".', | |||||
$function)); | |||||
} | |||||
if (!isset($table_map[$function])) { | if (!isset($table_map[$function])) { | ||||
$alias = 'ftfield'.$idx++; | $alias = 'ftfield'.$idx++; | ||||
$table_map[$function] = array( | $table_map[$function] = array( | ||||
'alias' => $alias, | 'alias' => $alias, | ||||
'key' => $function_map[$function], | 'key' => $raw_field, | ||||
); | ); | ||||
} | } | ||||
$current_function = $function; | $current_function = $function; | ||||
} | } | ||||
$this->ferretTables = $table_map; | $this->ferretTables = $table_map; | ||||
▲ Show 20 Lines • Show All 1,014 Lines • Show Last 20 Lines |