From: dcausse Date: Fri, 11 Mar 2016 08:30:34 +0000 (+0100) Subject: completionSearch: try an exact match even if the backend returns no result X-Git-Tag: 1.31.0-rc.0~7627^2 X-Git-Url: https://git.cyclocoop.org/admin/?a=commitdiff_plain;h=4c2f0e39401fdf2d95714fc26198162a4810efb8;p=lhc%2Fweb%2Fwiklou.git completionSearch: try an exact match even if the backend returns no result Unfortunately some backends (like Cirrus) are not able to do proper crossnamespace lookup. If the backend returns no result we should still try an exact title match. Bug:T129575 Change-Id: Ic08ec0aac0fd8a289f21753d74ae62ba509de841 --- diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 1344f4cf38..b263fb39e9 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -708,10 +708,6 @@ class SearchEngine { * @return SearchSuggestionSet */ protected function processCompletionResults( $search, SearchSuggestionSet $suggestions ) { - if ( $suggestions->getSize() == 0 ) { - // If we don't have anything, don't bother - return $suggestions; - } $search = trim( $search ); // preload the titles with LinkBatch $titles = $suggestions->map( function( SearchSuggestion $sugg ) { @@ -726,6 +722,10 @@ class SearchEngine { } ); // Rescore results with an exact title match + // NOTE: in some cases like cross-namespace redirects + // (frequently used as shortcuts e.g. WP:WP on huwiki) some + // backends like Cirrus will return no results. We should still + // try an exact title match to workaround this limitation $rescorer = new SearchExactMatchRescorer(); $rescoredResults = $rescorer->rescore( $search, $this->namespaces, $results, $this->limit );