Index: trunk/phase3/includes/SearchPostgres.php |
— | — | @@ -66,6 +66,7 @@ |
67 | 67 | |
68 | 68 | /* |
69 | 69 | * Transform the user's search string into a better form for tsearch2 |
| 70 | + * Returns an SQL fragment consisting of quoted text to search for. |
70 | 71 | */ |
71 | 72 | function parseQuery( $term ) { |
72 | 73 | |
— | — | @@ -142,6 +143,7 @@ |
143 | 144 | } |
144 | 145 | $prefix = $wgDBversion < 8.3 ? "'default'," : ''; |
145 | 146 | |
| 147 | + # Get the SQL fragment for the given term |
146 | 148 | $searchstring = $this->parseQuery( $term ); |
147 | 149 | |
148 | 150 | ## We need a separate query here so gin does not complain about empty searches |
— | — | @@ -183,7 +185,7 @@ |
184 | 186 | if ( count($this->namespaces) < 1) |
185 | 187 | $query .= ' AND page_namespace = 0'; |
186 | 188 | else { |
187 | | - $namespaces = implode( ',', $this->namespaces ); |
| 189 | + $namespaces = $this->db->makeList( $this->namespaces ); |
188 | 190 | $query .= " AND page_namespace IN ($namespaces)"; |
189 | 191 | } |
190 | 192 | } |
— | — | @@ -202,8 +204,8 @@ |
203 | 205 | function update( $pageid, $title, $text ) { |
204 | 206 | ## We don't want to index older revisions |
205 | 207 | $SQL = "UPDATE pagecontent SET textvector = NULL WHERE old_id IN ". |
206 | | - "(SELECT rev_text_id FROM revision WHERE rev_page = $pageid ". |
207 | | - "ORDER BY rev_text_id DESC OFFSET 1)"; |
| 208 | + "(SELECT rev_text_id FROM revision WHERE rev_page = " . intval( $pageid ) . |
| 209 | + " ORDER BY rev_text_id DESC OFFSET 1)"; |
208 | 210 | $this->db->doQuery($SQL); |
209 | 211 | return true; |
210 | 212 | } |
Index: trunk/phase3/includes/SearchOracle.php |
— | — | @@ -77,9 +77,10 @@ |
78 | 78 | function queryNamespaces() { |
79 | 79 | if( is_null($this->namespaces) ) |
80 | 80 | return ''; |
81 | | - $namespaces = implode(',', $this->namespaces); |
82 | | - if ($namespaces == '') { |
| 81 | + if ( !count( $this->namespaces ) ) { |
83 | 82 | $namespaces = '0'; |
| 83 | + } else { |
| 84 | + $namespaces = $this->db->makeList( $this->namespaces ); |
84 | 85 | } |
85 | 86 | return 'AND page_namespace IN (' . $namespaces . ')'; |
86 | 87 | } |
— | — | @@ -144,7 +145,10 @@ |
145 | 146 | 'WHERE page_id=si_page AND ' . $match; |
146 | 147 | } |
147 | 148 | |
148 | | - /** @todo document */ |
| 149 | + /** |
| 150 | + * Parse a user input search string, and return an SQL fragment to be used |
| 151 | + * as part of a WHERE clause |
| 152 | + */ |
149 | 153 | function parseQuery($filteredText, $fulltext) { |
150 | 154 | global $wgContLang; |
151 | 155 | $lc = SearchEngine::legalSearchChars(); |
— | — | @@ -170,9 +174,9 @@ |
171 | 175 | } |
172 | 176 | } |
173 | 177 | |
174 | | - $searchon = $this->db->strencode(join(',', $q)); |
| 178 | + $searchon = $this->db->addQuotes(join(',', $q)); |
175 | 179 | $field = $this->getIndexField($fulltext); |
176 | | - return " CONTAINS($field, '$searchon', 1) > 0 "; |
| 180 | + return " CONTAINS($field, $searchon, 1) > 0 "; |
177 | 181 | } |
178 | 182 | |
179 | 183 | /** |
Index: trunk/phase3/includes/SearchMySQL.php |
— | — | @@ -34,7 +34,10 @@ |
35 | 35 | $this->db = $db; |
36 | 36 | } |
37 | 37 | |
38 | | - /** @todo document */ |
| 38 | + /** |
| 39 | + * Parse the user's query and transform it into an SQL fragment which will |
| 40 | + * become part of a WHERE clause |
| 41 | + */ |
39 | 42 | function parseQuery( $filteredText, $fulltext ) { |
40 | 43 | global $wgContLang; |
41 | 44 | $lc = SearchEngine::legalSearchChars(); // Minus format chars |
— | — | @@ -126,9 +129,10 @@ |
127 | 130 | function queryNamespaces() { |
128 | 131 | if( is_null($this->namespaces) ) |
129 | 132 | return ''; # search all |
130 | | - $namespaces = implode( ',', $this->namespaces ); |
131 | | - if ($namespaces == '') { |
| 133 | + if ( !count( $this->namespaces ) ) { |
132 | 134 | $namespaces = '0'; |
| 135 | + } else { |
| 136 | + $namespaces = $this->db->makeList( $this->namespaces ); |
133 | 137 | } |
134 | 138 | return 'AND page_namespace IN (' . $namespaces . ')'; |
135 | 139 | } |