Index: trunk/phase3/includes/search/SearchOracle.php |
— | — | @@ -27,6 +27,34 @@ |
28 | 28 | * @ingroup Search |
29 | 29 | */ |
30 | 30 | class SearchOracle extends SearchEngine { |
| 31 | + |
| 32 | + private $reservedWords = array ('ABOUT' => 1, |
| 33 | + 'ACCUM' => 1, |
| 34 | + 'AND' => 1, |
| 35 | + 'BT' => 1, |
| 36 | + 'BTG' => 1, |
| 37 | + 'BTI' => 1, |
| 38 | + 'BTP' => 1, |
| 39 | + 'FUZZY' => 1, |
| 40 | + 'HASPATH' => 1, |
| 41 | + 'INPATH' => 1, |
| 42 | + 'MINUS' => 1, |
| 43 | + 'NEAR' => 1, |
| 44 | + 'NOT' => 1, |
| 45 | + 'NT' => 1, |
| 46 | + 'NTG' => 1, |
| 47 | + 'NTI' => 1, |
| 48 | + 'NTP' => 1, |
| 49 | + 'OR' => 1, |
| 50 | + 'PT' => 1, |
| 51 | + 'RT' => 1, |
| 52 | + 'SQE' => 1, |
| 53 | + 'SYN' => 1, |
| 54 | + 'TR' => 1, |
| 55 | + 'TRSYN' => 1, |
| 56 | + 'TT' => 1, |
| 57 | + 'WITHIN' => 1); |
| 58 | + |
31 | 59 | function __construct($db) { |
32 | 60 | $this->db = $db; |
33 | 61 | } |
— | — | @@ -191,6 +219,7 @@ |
192 | 220 | private function escapeTerm($t) { |
193 | 221 | global $wgContLang; |
194 | 222 | $t = $wgContLang->stripForSearch($t); |
| 223 | + $t = isset($this->reservedWords[strtoupper($t)]) ? '{'.$t.'}' : $t; |
195 | 224 | $t = preg_replace('/^"(.*)"$/', '($1)', $t); |
196 | 225 | $t = preg_replace('/([-&|])/', '\\\\$1', $t); |
197 | 226 | return $t; |