X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQuerySearch.php;h=51f799a25157a27582ebb9989824283711fe7867;hb=87070fc6743bfe5da7b49f07561fc1e0b03897c4;hp=66ef8db555485b454185288a5d61f453e8ac0fa8;hpb=b950468ceb58482568df18b72a597ceec63c11b6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php index 66ef8db555..51f799a251 100644 --- a/includes/api/ApiQuerySearch.php +++ b/includes/api/ApiQuerySearch.php @@ -204,47 +204,50 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { } $hasInterwikiResults = false; + $totalhits = null; if ( $interwiki && $resultPageSet === null && $matches->hasInterwikiResults() ) { - $matches = $matches->getInterwikiResults(); - $hasInterwikiResults = true; + foreach ( $matches->getInterwikiResults() as $matches ) { + $matches = $matches->getInterwikiResults(); + $hasInterwikiResults = true; - // Include number of results if requested - if ( $resultPageSet === null && isset( $searchInfo['totalhits'] ) ) { - $totalhits = $matches->getTotalHits(); - if ( $totalhits !== null ) { - $apiResult->addValue( array( 'query', 'interwikisearchinfo' ), - 'totalhits', $totalhits ); + // Include number of results if requested + if ( $resultPageSet === null && isset( $searchInfo['totalhits'] ) ) { + $totalhits += $matches->getTotalHits(); } - } - $result = $matches->next(); - while ( $result ) { - $title = $result->getTitle(); - - if ( $resultPageSet === null ) { - $vals = array( - 'namespace' => $result->getInterwikiNamespaceText(), - 'title' => $title->getText(), - 'url' => $title->getFullUrl(), - ); - - // Add item to results and see whether it fits - $fit = $apiResult->addValue( - array( 'query', 'interwiki' . $this->getModuleName(), $result->getInterwikiPrefix() ), - null, - $vals - ); - - if ( !$fit ) { - // We hit the limit. We can't really provide any meaningful - // pagination info so just bail out - break; + $result = $matches->next(); + while ( $result ) { + $title = $result->getTitle(); + + if ( $resultPageSet === null ) { + $vals = array( + 'namespace' => $result->getInterwikiNamespaceText(), + 'title' => $title->getText(), + 'url' => $title->getFullUrl(), + ); + + // Add item to results and see whether it fits + $fit = $apiResult->addValue( + array( 'query', 'interwiki' . $this->getModuleName(), $result->getInterwikiPrefix() ), + null, + $vals + ); + + if ( !$fit ) { + // We hit the limit. We can't really provide any meaningful + // pagination info so just bail out + break; + } + } else { + $titles[] = $title; } - } else { - $titles[] = $title; - } - $result = $matches->next(); + $result = $matches->next(); + } + } + if ( $totalhits !== null ) { + $apiResult->addValue( array( 'query', 'interwikisearchinfo' ), + 'totalhits', $totalhits ); } } @@ -329,7 +332,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { ); $alternatives = SearchEngine::getSearchTypes(); - if ( count( $alternatives ) > 1 ) { + if ( count( $alternatives ) > 0 ) { if ( $alternatives[0] === null ) { $alternatives[0] = self::BACKEND_NULL_PARAM; }