Fix Undefined index: 0 in SearchExactMatchRescorer.php on line 44
authordcausse <dcausse@wikimedia.org>
Thu, 31 Mar 2016 13:57:36 +0000 (15:57 +0200)
committerdcausse <dcausse@wikimedia.org>
Thu, 31 Mar 2016 14:26:37 +0000 (16:26 +0200)
It seems to happen when opensearch or prefixsearch api is called with an
invalid namespace parameter.

Change-Id: I1dda12c93db03c520080e8ee57bd750396905a58

includes/search/SearchExactMatchRescorer.php

index d3b9d5c..40cfe39 100644 (file)
@@ -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