- $prev = null;
- $result = $matches->next();
- while ( $result ) {
- $out .= $this->showInterwikiHit( $result, $prev, $terms, $query, $customCaptions );
- $prev = $result->getInterwikiPrefix();
- $result = $matches->next();
+ if ( !is_array( $matches ) ) {
+ $matches = array( $matches );
+ }
+
+ foreach ( $matches as $set ) {
+ $prev = null;
+ $result = $set->next();
+ while ( $result ) {
+ $out .= $this->showInterwikiHit( $result, $prev, $query, $customCaptions );
+ $prev = $result->getInterwikiPrefix();
+ $result = $set->next();
+ }