Index: trunk/extensions/SphinxSearch/SphinxSearch.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | |
13 | 13 | $wgExtensionCredits['other'][] = array( |
14 | 14 | 'path' => __FILE__, |
15 | | - 'version' => '0.8.3', |
| 15 | + 'version' => '0.8.4', |
16 | 16 | 'name' => 'SphinxSearch', |
17 | 17 | 'author' => array( 'Svemir Brkic', 'Paul Grinberg' ), |
18 | 18 | 'url' => 'http://www.mediawiki.org/wiki/Extension:SphinxSearch', |
Index: trunk/extensions/SphinxSearch/SphinxMWSearch.php |
— | — | @@ -100,8 +100,10 @@ |
101 | 101 | } |
102 | 102 | } |
103 | 103 | $term = str_replace($placeholders, array_keys($placeholders), $term); |
| 104 | + $term = addcslashes( $term, $escape ); |
| 105 | + wfDebug( "SphinxSearch query: $term\n" ); |
104 | 106 | $resultSet = $this->sphinx_client->Query( |
105 | | - addcslashes( $term, $escape ), |
| 107 | + $term, |
106 | 108 | $wgSphinxSearch_index_list |
107 | 109 | ); |
108 | 110 | } else { |
— | — | @@ -157,9 +159,11 @@ |
158 | 160 | } |
159 | 161 | if ( $this->categories && count( $this->categories ) ) { |
160 | 162 | $cl->SetFilter( 'category', $this->categories ); |
| 163 | + wfDebug( "SphinxSearch included categories: " . join( ', ', $this->categories ) . "\n" ); |
161 | 164 | } |
162 | 165 | if ( $this->exc_categories && count( $this->exc_categories ) ) { |
163 | 166 | $cl->SetFilter( 'category', $this->exc_categories, true ); |
| 167 | + wfDebug( "SphinxSearch excluded categories: " . join( ', ', $this->exc_categories ) . "\n" ); |
164 | 168 | } |
165 | 169 | $cl->SetSortMode( $wgSphinxSearch_sortmode, $wgSphinxSearch_sortby ); |
166 | 170 | $cl->SetLimits( |
— | — | @@ -201,7 +205,7 @@ |
202 | 206 | $parts = preg_split( '/(")/', $query, -1, PREG_SPLIT_DELIM_CAPTURE ); |
203 | 207 | $inquotes = false; |
204 | 208 | $rewritten = ''; |
205 | | - foreach ( $parts as $part ) { |
| 209 | + foreach ( $parts as $key => $part ) { |
206 | 210 | if ( $part == '"' ) { // stuff in quotes doesn't get rewritten |
207 | 211 | $rewritten .= $part; |
208 | 212 | $inquotes = !$inquotes; |
— | — | @@ -211,7 +215,7 @@ |
212 | 216 | if ( strpos( $query, ':' ) !== false ) { |
213 | 217 | $regexp = $this->preparePrefixRegexp(); |
214 | 218 | $part = preg_replace_callback( |
215 | | - '/(^|[| :])(' . $regexp . '):([^ ]+)/i', |
| 219 | + '/(^|[| :]|-)(' . $regexp . '):([^ ]+)/i', |
216 | 220 | array( $this, 'replaceQueryPrefix' ), |
217 | 221 | $part |
218 | 222 | ); |
— | — | @@ -309,7 +313,12 @@ |
310 | 314 | ), |
311 | 315 | __METHOD__ |
312 | 316 | ); |
313 | | - $this->categories[] = intval( $page_id ); |
| 317 | + $category = intval( $page_id ); |
| 318 | + if ( $matches[ 1 ] === '-' ) { |
| 319 | + $this->exc_categories[ ] = $category; |
| 320 | + } else { |
| 321 | + $this->categories[ ] = $category; |
| 322 | + } |
314 | 323 | return ''; |
315 | 324 | } |
316 | 325 | |