private function searchTextSecondTry($term, ResultSet $oldResult)
 {
     // TODO: figure out who goes first - language or suggestion?
     if ($oldResult->numRows() == 0 && $oldResult->hasSuggestion()) {
         $rewritten = $oldResult->getSuggestionQuery();
         $rewrittenSnippet = $oldResult->getSuggestionSnippet();
         $this->showSuggestion = false;
         $rewrittenResult = $this->searchTextReal($rewritten);
         if ($rewrittenResult instanceof ResultSet && $rewrittenResult->numRows() > 0) {
             $rewrittenResult->setRewrittenQuery($rewritten, $rewrittenSnippet);
             if ($rewrittenResult->numRows() < $GLOBALS['wgCirrusSearchInterwikiThreshold']) {
                 // replace the result but still try the alt language
                 $oldResult = $rewrittenResult;
             } else {
                 return $rewrittenResult;
             }
         }
     }
     $altWiki = $this->hasSecondaryLanguage($term);
     if ($altWiki) {
         try {
             $config = new SearchConfig($altWiki[0], $altWiki[1]);
         } catch (MWException $e) {
             LoggerFactory::getInstance('CirrusSearch')->info("Failed to get config for {interwiki}:{dbwiki}", array("interwiki" => $altWiki[0], "dbwiki" => $altWiki[1], "exception" => $e));
             $config = null;
         }
         if ($config) {
             $matches = $this->searchTextReal($term, $config);
             if ($matches instanceof ResultSet && $matches->numRows() > 0) {
                 $oldResult->addInterwikiResults($matches, SearchResultSet::INLINE_RESULTS, $altWiki[1]);
             }
         }
     }
     // Don't have any other options yet.
     return $oldResult;
 }
 private function searchTextSecondTry($term, ResultSet $zeroResult)
 {
     // TODO: figure out who goes first - language or suggestion?
     if ($zeroResult->hasSuggestion()) {
         $rewritten = $zeroResult->getSuggestionQuery();
         $rewrittenSnippet = $zeroResult->getSuggestionSnippet();
         $this->showSuggestion = false;
     } else {
         $altWiki = $this->hasSecondaryLanguage($term);
         if ($altWiki) {
             try {
                 $config = new SearchConfig($altWiki[0], $altWiki[1]);
             } catch (MWException $e) {
                 wfDebug("Failed to get {$altWiki} config: {$e->getMessage()}");
                 $config = null;
             }
             if ($config) {
                 $matches = $this->searchTextReal($term, $config);
                 return $matches;
             }
         }
         // Don't have any other options yet.
         return $zeroResult;
     }
     $rewrittenResult = $this->searchTextReal($rewritten);
     if ($rewrittenResult instanceof ResultSet && $rewrittenResult->numRows() > 0) {
         $rewrittenResult->setRewrittenQuery($rewritten, $rewrittenSnippet);
         return $rewrittenResult;
     } else {
         return $zeroResult;
     }
 }
 /**
  * Loads the result set into the mediawiki LinkCache via a
  * batch query. By pre-caching this we ensure methods such as
  * Result::isMissingRevision() don't trigger a query for each and
  * every search result.
  * @param ResultSet $resultSet Result set from which the titles come
  */
 private function preCacheContainedTitles($resultSet)
 {
     // We can only pull in information about the local wiki
     if ($this->interwikiPrefix !== '') {
         return;
     }
     $lb = new LinkBatch();
     foreach ($resultSet->getResults() as $result) {
         $lb->add($result->namespace, $result->title);
     }
     if (!$lb->isEmpty()) {
         $lb->setCaller(__METHOD__);
         $lb->execute();
     }
 }