Page MenuHomePhabricator

Cleanup CirrusSearch.php and remove dynamic/non configuration vars
Closed, ResolvedPublic

Description

CirrusSearch.php is not designed to be used in a migration script that will generate extension.php automatically. Several problems exist in this file that should be resolved first.

dynamic settings

$wgCirrusSearchIndexBaseName = wfWikiID();

These dynamic config var will be resolved at migration with a default value like:

"CirrusSearchIndexBaseName": {
        "value": "wikidb-mw_"
},

Unless there is a way to support "dynamic" with extension.json, we should remove this line from CirrusSearch.php and defer setting wgCirrusSearchIndexBaseName in the code when unset.

code/registry/factory setup
Sometimes with use php constants, these are also resolved by the migration script and become hard to read :

/**
 * Mapping of result types to CirrusSearch classes.
 */
$wgCirrusSearchFieldTypes = array(
	SearchIndexField::INDEX_TYPE_TEXT => \CirrusSearch\Search\TextIndexField::class,
	SearchIndexField::INDEX_TYPE_KEYWORD => \CirrusSearch\Search\KeywordIndexField::class,
[...]
);

will become:

          "CirrusSearchFieldTypes": {
			"value": {
				"0": "CirrusSearch\\Search\\TextIndexField",
				"1": "CirrusSearch\\Search\\KeywordIndexField",
[...]			}
		},

Maybe moving this into an extension hook would be appropriate.

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.

Event Timeline

dcausse moved this task from needs triage to This Quarter on the Discovery-Search board.
dcausse moved this task from This Quarter to search-icebox on the Discovery-Search board.

Variables that have non-plain values (causes listed above):

  • $wgCirrusSearchNamespaceWeights
  • $wgCirrusSearchDropDelayedJobsAfter
  • $wgMessagesDirs['CirrusSearch']
  • $wgResourceModules
  • $wgCirrusSearchFieldTypes
  • $wgCirrusSearchFieldTypeOverrides

Change 505063 had a related patch set uploaded (by Smalyshev; owner: Smalyshev):
[mediawiki/core@master] Define index types as strings

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

Change 505063 merged by jenkins-bot:
[mediawiki/core@master] Define index types as strings

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

Smalyshev claimed this task.

I think most problems blocking the conversion are resolved now.