Index: trunk/extensions/MWSearch/MWSearch_body.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | */ |
12 | 12 | function searchText( $term ) { |
13 | 13 | return LuceneSearchSet::newFromQuery( isset($this->related)? 'related' : 'search', |
14 | | - $term, $this->namespaces, $this->limit, $this->offset ); |
| 14 | + $term, $this->namespaces, $this->limit, $this->offset, $this->searchingEverything() ); |
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
— | — | @@ -36,6 +36,15 @@ |
37 | 37 | |
38 | 38 | return false; |
39 | 39 | } |
| 40 | + |
| 41 | + /** |
| 42 | + * Check if we are searching all the namespaces on this wiki |
| 43 | + * |
| 44 | + * @return boolean |
| 45 | + */ |
| 46 | + function searchingEverything(){ |
| 47 | + return $this->namespaces == array_keys( SearchEngine::searchableNamespaces() ); |
| 48 | + } |
40 | 49 | |
41 | 50 | /** |
42 | 51 | * Prepare query for the lucene-search daemon: |
— | — | @@ -60,14 +69,8 @@ |
61 | 70 | $inquotes = false; |
62 | 71 | |
63 | 72 | // "search everything" keyword |
64 | | - $allkeyword = wfMsgForContent('searchall'); |
| 73 | + $allkeyword = wfMsgForContent('searchall'); |
65 | 74 | |
66 | | - // if all namespaces are set, convert to prefixed all: syntax which is more quickly handled by backend |
67 | | - $nsAllSet = array_keys( SearchEngine::searchableNamespaces() ); |
68 | | - if( $this->namespaces == $nsAllSet && strncmp($query, $allkeyword, strlen($allkeyword)) != 0){ |
69 | | - $query = $allkeyword.':'.$query; |
70 | | - } |
71 | | - |
72 | 75 | $qlen = strlen($query); |
73 | 76 | |
74 | 77 | // quick check, most of the time we don't need any rewriting |
— | — | @@ -424,10 +427,13 @@ |
425 | 428 | * @param string $query |
426 | 429 | * @param int $limit |
427 | 430 | * @param int $offset |
| 431 | + * @param bool $searchAll |
428 | 432 | * @return array |
429 | 433 | * @access public |
430 | 434 | */ |
431 | | - static function newFromQuery( $method, $query, $namespaces = array(), $limit = 20, $offset = 0 ) { |
| 435 | + static function newFromQuery( $method, $query, $namespaces = array(), |
| 436 | + $limit = 20, $offset = 0, $searchAll = False ) { |
| 437 | + |
432 | 438 | $fname = 'LuceneSearchSet::newFromQuery'; |
433 | 439 | wfProfileIn( $fname ); |
434 | 440 | |
— | — | @@ -457,6 +463,7 @@ |
458 | 464 | 'limit' => $limit, |
459 | 465 | 'version' => $wgLuceneSearchVersion, |
460 | 466 | 'iwlimit' => 10, |
| 467 | + 'searchall' => $searchAll? 1 : 0, |
461 | 468 | ) ); |
462 | 469 | |
463 | 470 | // try to fetch cached if caching is turned on |