/** * Check whether we want to try another language. * @param string $term Search term * @return array|null Array of (interwiki, dbname) for another wiki to try, or null */ private function hasSecondaryLanguage($term) { if (empty($GLOBALS['wgCirrusSearchLanguageToWikiMap']) || empty($GLOBALS['wgCirrusSearchWikiToNameMap'])) { // map's empty - no need to bother with detection return null; } $detected = null; $arguments = array($this, $term); foreach ($GLOBALS['wgCirrusSearchLanguageDetectors'] as $name => $callback) { $lang = call_user_func_array($callback, $arguments); $wiki = self::wikiForLanguage($lang); if ($wiki !== null) { // it might be more accurate to attach these to the 'next' // log context? It would be inconsistent with the // langdetect => false condition which does not have a next // request though. Searcher::appendLastLogContext(array('langdetect' => $name)); $detected = $wiki; break; } } if ($detected === null) { Searcher::appendLastLogContext(array('langdetect' => 'failed')); } // check whether we have second language functionality enabled. // This comes after the actual detection so we can include the // results of detection in AB test control buckets. if (!$GLOBALS['wgCirrusSearchEnableAltLanguage']) { return null; } return $detected; }