Page MenuHomePhabricator

Deal with dropping of Global CirrusSearch class
Closed, ResolvedPublic

Description

$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();
		}

Event Timeline

Reedy created this task.Apr 21 2020, 2:53 PM
Restricted Application added a project: Discovery-Search. · View Herald TranscriptApr 21 2020, 2:53 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 591116 had a related patch set uploaded (by Reedy; owner: Reedy):
[mediawiki/extensions/CirrusSearch@master] Allow using namespaced CirrusSearch\\CirrusSearch class for $wgSearchType

https://gerrit.wikimedia.org/r/591116

Reedy updated the task description. (Show Details)Apr 21 2020, 3:00 PM
Reedy updated the task description. (Show Details)
Reedy updated the task description. (Show Details)Apr 24 2020, 2:18 AM
Reedy updated the task description. (Show Details)Apr 24 2020, 2:26 AM

Change 592656 had a related patch set uploaded (by Reedy; owner: Reedy):
[mediawiki/extensions/CirrusSearch@master] Add "SearchMappings" to extension.json

https://gerrit.wikimedia.org/r/592656

Change 591116 abandoned by Reedy:
Allow using namespaced CirrusSearch\\CirrusSearch class for $wgSearchType

Reason:
In favour of https://gerrit.wikimedia.org/r/592656

https://gerrit.wikimedia.org/r/591116

Reedy changed the task status from Stalled to Open.Apr 30 2020, 2:20 PM

Change 592656 merged by jenkins-bot:
[mediawiki/extensions/CirrusSearch@master] Add "SearchMappings" to extension.json

https://gerrit.wikimedia.org/r/592656

Change 591356 had a related patch set uploaded (by Reedy; owner: Reedy):
[mediawiki/extensions/CirrusSearch@master] Drop global namespace CirrusSearch class

https://gerrit.wikimedia.org/r/591356

Reedy added a comment.May 2 2020, 1:46 AM

https://gerrit.wikimedia.org/r/591198 and https://gerrit.wikimedia.org/r/591200 cleared up the last few usages of the global CirrusSearch class in our hosted extensions/code

Change 591356 merged by jenkins-bot:
[mediawiki/extensions/CirrusSearch@master] Drop global namespace CirrusSearch class

https://gerrit.wikimedia.org/r/591356

Reedy closed this task as Resolved.May 4 2020, 5:13 PM
Reedy claimed this task.