+ $hasInterwikiResults = false;
+ if ( $interwiki && $resultPageSet === null && $matches->hasInterwikiResults() ) {
+ $matches = $matches->getInterwikiResults();
+ $iwprefixes = array();
+ $hasInterwikiResults = true;
+
+ // Include number of results if requested
+ if ( isset( $searchInfo['totalhits'] ) ) {
+ $totalhits = $matches->getTotalHits();
+ if ( $totalhits !== null ) {
+ $apiResult->addValue( array( 'query', 'interwikisearchinfo' ),
+ 'totalhits', $totalhits );
+ }
+ }
+
+ $result = $matches->next();
+ while ( $result ) {
+ $title = $result->getTitle();
+ $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();
+ }
+ }
+