Repair interwiki search via api
authorErik Bernhardson <ebernhardson@wikimedia.org>
Thu, 30 Jun 2016 22:55:20 +0000 (15:55 -0700)
committerErik Bernhardson <ebernhardson@wikimedia.org>
Thu, 30 Jun 2016 22:55:20 +0000 (15:55 -0700)
This was throwing exceptions, probably for many months now, when
requesting and finding interwiki search results. Probably this went
unnoticed due to interwiki search only being enabled on itwiki, and
the requirement to pass a special parameter to turn it on.

Change-Id: I68ec35bb072b5ad62dd66789936bc2ae47d5256f

includes/api/ApiQuerySearch.php

index f84f806..4377831 100644 (file)
@@ -232,15 +232,14 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                $totalhits = null;
                if ( $interwiki && $resultPageSet === null && $matches->hasInterwikiResults() ) {
                        foreach ( $matches->getInterwikiResults() as $interwikiMatches ) {
-                               $currentMatches = $interwikiMatches->getInterwikiResults();
                                $hasInterwikiResults = true;
 
                                // Include number of results if requested
                                if ( $resultPageSet === null && isset( $searchInfo['totalhits'] ) ) {
-                                       $totalhits += $currentMatches->getTotalHits();
+                                       $totalhits += $interwikiMatches->getTotalHits();
                                }
 
-                               $result = $currentMatches->next();
+                               $result = $interwikiMatches->next();
                                while ( $result ) {
                                        $title = $result->getTitle();
 
@@ -267,7 +266,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                                                $titles[] = $title;
                                        }
 
-                                       $result = $currentMatches->next();
+                                       $result = $interwikiMatches->next();
                                }
                        }
                        if ( $totalhits !== null ) {