Index: trunk/extensions/MWSearch/MWSearch.php |
— | — | @@ -54,6 +54,9 @@ |
55 | 55 | # hit rates way below 1% even for very long expiry times |
56 | 56 | $wgLuceneSearchCacheExpiry = 0; |
57 | 57 | |
| 58 | +# timeout for search backend to respond |
| 59 | +$wgLuceneSearchTimeout = 6; |
| 60 | + |
58 | 61 | $wgExtensionCredits['other'][] = array( |
59 | 62 | 'name' => 'MWSearch', |
60 | 63 | 'svn-date' => '$LastChangedDate$', |
Index: trunk/extensions/MWSearch/MWSearch_body.php |
— | — | @@ -55,12 +55,22 @@ |
56 | 56 | global $wgContLang, $wgLuceneUseRelated; |
57 | 57 | $fname = 'LuceneSearch::replacePrefixes'; |
58 | 58 | wfProfileIn($fname); |
59 | | - $qlen = strlen($query); |
60 | 59 | $start = 0; $len = 0; // token start pos and length |
61 | 60 | $rewritten = ''; // rewritten query |
62 | 61 | $rindex = 0; // point to last rewritten character |
63 | 62 | $inquotes = false; |
64 | 63 | |
| 64 | + // "search everything" keyword |
| 65 | + $allkeyword = wfMsgForContent('searchall'); |
| 66 | + |
| 67 | + // if all namespaces are set, convert to prefixed all: syntax which is more quickly handled by backend |
| 68 | + $nsAllSet = array_keys( SearchEngine::searchableNamespaces() ); |
| 69 | + if( $this->namespaces == $nsAllSet && strncmp($query, $allkeyword, strlen($allkeyword)) != 0){ |
| 70 | + $query = $allkeyword.':'.$query; |
| 71 | + } |
| 72 | + |
| 73 | + $qlen = strlen($query); |
| 74 | + |
65 | 75 | // quick check, most of the time we don't need any rewriting |
66 | 76 | if(strpos($query,':')===false){ |
67 | 77 | wfProfileOut($fname); |
— | — | @@ -76,10 +86,6 @@ |
77 | 87 | return trim($ret); |
78 | 88 | } |
79 | 89 | |
80 | | - // "search everything" |
81 | | - // might not be at the beginning for complex queries |
82 | | - $allkeyword = wfMsgForContent('searchall'); |
83 | | - |
84 | 90 | for($i = 0 ; $i < $qlen ; $i++){ |
85 | 91 | $c = $query[$i]; |
86 | 92 | |
— | — | @@ -152,6 +158,10 @@ |
153 | 159 | wfProfileOut($fname); |
154 | 160 | return $rewritten; |
155 | 161 | } |
| 162 | + |
| 163 | + function acceptListRedirects() { |
| 164 | + return false; |
| 165 | + } |
156 | 166 | } |
157 | 167 | |
158 | 168 | class LuceneResult extends SearchResult { |
— | — | @@ -437,6 +447,7 @@ |
438 | 448 | |
439 | 449 | global $wgLuceneHost, $wgLucenePort, $wgDBname, $wgMemc; |
440 | 450 | global $wgLuceneSearchVersion, $wgLuceneSearchCacheExpiry; |
| 451 | + global $wgLuceneSearchTimeout; |
441 | 452 | |
442 | 453 | if( is_array( $wgLuceneHost ) ) { |
443 | 454 | $pick = mt_rand( 0, count( $wgLuceneHost ) - 1 ); |
— | — | @@ -469,7 +480,7 @@ |
470 | 481 | wfDebug( "Fetching search data from $searchUrl\n" ); |
471 | 482 | wfSuppressWarnings(); |
472 | 483 | wfProfileIn( $fname.'-contact-'.$host ); |
473 | | - $data = Http::get( $searchUrl ); |
| 484 | + $data = Http::get( $searchUrl, $wgLuceneSearchTimeout ); |
474 | 485 | wfProfileOut( $fname.'-contact-'.$host ); |
475 | 486 | wfRestoreWarnings(); |
476 | 487 | if( $data === false ) { |