@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.

Add "absent" and "present" field operators to the Ferret query compiler

Summary: Ref T13509. Parse "xyz:-" as "xyz is absent" and "xyz:~" as "xyz is present". These are new operators which the compiler emits separately from "not" and "substring".

Test Plan: Added unit tests, ran unit tests.

Maniphest Tasks: T13509

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

+32
+18
src/applications/search/compiler/PhutilSearchQueryCompiler.php
··· 12 12 const OPERATOR_AND = 'and'; 13 13 const OPERATOR_SUBSTRING = 'sub'; 14 14 const OPERATOR_EXACT = 'exact'; 15 + const OPERATOR_ABSENT = 'absent'; 16 + const OPERATOR_PRESENT = 'present'; 15 17 16 18 public function setOperators($operators) { 17 19 $this->operators = $operators; ··· 300 302 $require_value = $is_quoted; 301 303 302 304 switch ($operator) { 305 + case self::OPERATOR_NOT: 306 + if ($enable_functions && ($token['function'] !== null)) { 307 + $operator = self::OPERATOR_ABSENT; 308 + $value = null; 309 + } else { 310 + $require_value = true; 311 + } 312 + break; 313 + case self::OPERATOR_SUBSTRING: 314 + if ($enable_functions && ($token['function'] !== null)) { 315 + $operator = self::OPERATOR_PRESENT; 316 + $value = null; 317 + } else { 318 + $require_value = true; 319 + } 320 + break; 303 321 default: 304 322 $require_value = true; 305 323 break;
+14
src/applications/search/compiler/__tests__/PhutilSearchQueryCompilerTestCase.php
··· 97 97 $op_and = PhutilSearchQueryCompiler::OPERATOR_AND; 98 98 $op_sub = PhutilSearchQueryCompiler::OPERATOR_SUBSTRING; 99 99 $op_exact = PhutilSearchQueryCompiler::OPERATOR_EXACT; 100 + $op_present = PhutilSearchQueryCompiler::OPERATOR_PRESENT; 101 + $op_absent = PhutilSearchQueryCompiler::OPERATOR_ABSENT; 100 102 101 103 $mao = "\xE7\x8C\xAB"; 102 104 ··· 142 144 'title:' => false, 143 145 'title:+' => false, 144 146 'title:+""' => false, 147 + 'title:""' => false, 148 + 149 + 'title:~' => array( 150 + array('title', $op_present, null), 151 + ), 152 + 153 + 'title:-' => array( 154 + array('title', $op_absent, null), 155 + ), 156 + 157 + '~' => false, 158 + '-' => false, 145 159 ); 146 160 147 161 $this->assertCompileFunctionQueries($function_tests);