Don't reuse variable names
authorErik Bernhardson <ebernhardson@wikimedia.org>
Thu, 30 Jun 2016 22:11:41 +0000 (15:11 -0700)
committerErik Bernhardson <ebernhardson@wikimedia.org>
Thu, 30 Jun 2016 22:17:21 +0000 (15:17 -0700)
This code was rather hard to follow due to reusing the same variable
multiple times. Lets give them unique names.

Change-Id: I8f134b6314d593a3e40b19765c7b71496b8e524d

includes/api/ApiQuerySearch.php

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