Page MenuHomePhabricator

Migrate Wikibase Settings to mediawiki config handler
Open, Needs TriagePublic

Description

The current configuration system in Wikibase depends on two global variables: $wgWBRepoSettings and $wgWBClientSettings and sysadmins can customize a wiki by modifying this global variable directly:

$wgWBRepoSettings['serializationFormat'] = 'application/json';

and in turn, WikibaseSettings tries to build a SettingsArray (this class has issues like being mutable meaning config can change on the fly, joy). This also means merging configuration can be tricky and complicated: T257447: Don’t load Repo settings in PHP entry point and T256252: Migrate wgWBClientDataTypes + wgWBClientSettings loading out of Client PHP entry point.

The plausible solution is to migrate to config management in core: Documentation. But any sort of work requires lots of changes by sysadmins (like $wgWBRepoSettings['serializationFormat'] -> $wgWBRepoSettingsSerializationFormat ) and keeping backward compatibility is borderline impossible (what if one of them gets overriden by the sysadmin and not the other, what if they diverge drastically, etc..). So here's my proposed solution:

  • Define a new implementation of Config in core, something like GlobalArrayConfig (vs. GlobalVarConfig). Which takes name of a global array (like $wgWBRepoSettings) and returns the configs as part of that array.
  • Make ConfigFactory work with ObjectFactory, so we would be able to define such thing in extension.json and set the variable name for Wikibase:
{
	"ConfigRegistry": {
		"wikibaseRepo": {
			"factory": "GlobalArrayConfig::newInstance",
			"args": ["wgWBRepoSettings"]
		}
	}
}
  • Build an adapter for Config to SettingsArray and use it in WikibaseSettings.
  • Slowly migrate configs to extnesion.json
  • Drop WikibaseSettings and other bits

Does this make sense?

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 22 2020, 9:36 PM

I think in general your plan sounds good, but you can just do it all in Wikibase. Just define the GlobalArrayConfig class in Wikibase, and have the factory function pass $wgWBRepoSettings to the new instance.

Maybe I'm missing something obvious but I can't find a way to pass $wgWBRepoSettings to the factory function, the config registry or config factory doesn't support ObjectFactory and it just does this:

$conf = call_user_func( $this->factoryFunctions[$key], $this );

Can you help me figure out what I'm missing?

class WikibaseGlobalArrayConfig {
 public static function factory() {
  global $wgWBRepoSettings;
  return new self ( $wgWBRepoSettings );
 }

 public function __construct( array $settings ) {
  ...
 }
}
Akuckartz added a subscriber: Akuckartz.