From: dcausse Date: Thu, 31 Mar 2016 13:57:36 +0000 (+0200) Subject: Fix Undefined index: 0 in SearchExactMatchRescorer.php on line 44 X-Git-Tag: 1.31.0-rc.0~7410^2 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=6cbd56954e53e2c9bd839b75f484fa6f9372251c;p=lhc%2Fweb%2Fwiklou.git Fix Undefined index: 0 in SearchExactMatchRescorer.php on line 44 It seems to happen when opensearch or prefixsearch api is called with an invalid namespace parameter. Change-Id: I1dda12c93db03c520080e8ee57bd750396905a58 --- diff --git a/includes/search/SearchExactMatchRescorer.php b/includes/search/SearchExactMatchRescorer.php index d3b9d5cb0f..40cfe39305 100644 --- a/includes/search/SearchExactMatchRescorer.php +++ b/includes/search/SearchExactMatchRescorer.php @@ -41,7 +41,7 @@ class SearchExactMatchRescorer { */ public function rescore( $search, $namespaces, $srchres, $limit ) { // Pick namespace (based on PrefixSearch::defaultSearchBackend) - $ns = in_array( NS_MAIN, $namespaces ) ? NS_MAIN : $namespaces[0]; + $ns = in_array( NS_MAIN, $namespaces ) ? NS_MAIN : reset( $namespaces ); $t = Title::newFromText( $search, $ns ); if ( !$t || !$t->exists() ) { // No exact match so just return the search results