From 6cbd56954e53e2c9bd839b75f484fa6f9372251c Mon Sep 17 00:00:00 2001 From: dcausse Date: Thu, 31 Mar 2016 15:57:36 +0200 Subject: [PATCH] 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 --- includes/search/SearchExactMatchRescorer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- 2.20.1