$wgSearchType is used to instantiate the search class.
If we just change it from 'CirrusSearch' to 'CirrusSearch\CirrusSearch' (namespaced class), this will immediately break things like API clients that pass srbackend=cirrussearch (though, not an issue on Wikimedia wikis)
We might need some sort of migration/deprecation strategy...
Can we do this with $wgSearchTypeAlternatives, some documentation/announcements, waiting some time, and then removing it?
Or should we have some sort of mapping? 'searchdisplayname' => 'SearchClassName' Rather than just expecting the class to be instantiateable and just work... Might fork this to a seperate task
SearchEngineConfig.php:
/** * Return the search engines we support. If only $wgSearchType * is set, it'll be an array of just that one item. * * @return array */ public function getSearchTypes() { $alternatives = $this->config->get( 'SearchTypeAlternatives' ) ?: []; array_unshift( $alternatives, $this->config->get( 'SearchType' ) ); return $alternatives; } /** * Return the search engine configured in $wgSearchType, etc. * * @return string|null */ public function getSearchType() { return $this->config->get( 'SearchType' ); }
SearchApi.php
$searchConfig = MediaWikiServices::getInstance()->getSearchEngineConfig(); $alternatives = $searchConfig->getSearchTypes(); if ( count( $alternatives ) > 1 ) { if ( $alternatives[0] === null ) { $alternatives[0] = self::$BACKEND_NULL_PARAM; } $params['backend'] = [ ApiBase::PARAM_DFLT => $searchConfig->getSearchType(), ApiBase::PARAM_TYPE => $alternatives, ]; // @todo: support profile selection when multiple // backends are available. The solution could be to // merge all possible profiles and let ApiBase // subclasses do the check. Making ApiHelp and ApiSandbox // comprehensive might be more difficult. } else { $params += $this->buildProfileApiParam(); }