Page MenuHomePhabricator

Hide Cite community config when the CiteBacklinkCommunityConfiguration flag is off
Closed, ResolvedPublic

Description

Currently the community config page is always visible because the default Provider we have configured in the extension.json does not allow us to toggle the interface dynamically. We want to change that and set the visibility depending on the CiteBacklinkCommunityConfiguration flag.

Implementation:

  • I guess we need to implement our own Provider class by inheriting from MediaWikiConfigProvider
  • Then we can make sure that MediaWikiConfigProvider::getOptionValue( 'excludeFromUI' ) returns false / true depending on the config setting

Event Timeline

I guess we need to implement our own Provider class by inheriting from MediaWikiConfigProvider

Another approach (that eg. Babel or GrowthExperiments is using) is loading the config using a service that looks like this:

'Extension.Config' => static function ( MediaWikiServices $services ): Config {
	if ( Utils::useCommunityConfiguration() ) {
		return new CommunityConfigurationServices::wrap( $services )->getMediaWikiConfigReader();
	} else {
		return $services->getMainConfig();
	}
}

where Utils::useCommunityConfiguration() decides whether CommunityConfiguration is supposed to be in use or not. Babel implements it by checking both ExtensionRegistry::isLoaded( 'CommunityConfiguration' ) and a feature flag (such as BabelUseCommunityConfiguration). Unlike what the description suggests, Babel's feature flag puts CommunityConfiguration completely out of the way (so it is not specific to a given feature).

Using this approach, you can maintain soft-dependency on CommunityConfiguration, making Cite work even on wikis where it is not available. This is probably a good idea regardless (to introduce CommunityConfiguration first as an option rather than as a mandatory feature).

If you want to keep the ability to not route certain things to CommunityConfiguration (either never, or based on a feature flag), you can wrap CommunityConfiguration's Config implementation in your own. You can see an example usage in Babel.

Then we can make sure that MediaWikiConfigProvider::getOptionValue( 'excludeFromUI' ) returns false / true depending on the config setting

Note this would only make CommunityConfiguration exclude the page from the UI. In the background, everything would be still routed through CC. If someone edits the wikipage manually, those changes would be respected. This option is useful for cases where you have a system usage of CommunityConfiguration (it is used as a background mechanism, but you don't really want to expose that to the users).

Hope this helps!

Thanks @Urbanecm_WMF that's indeed very helpful. I guess what Babel is doing is exactly hat we need. 🥳

Change #1115387 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/Cite@master] CommunityConfiguration: Only show the interface when the flag is enabled

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

Change #1115387 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] CommunityConfiguration: Add feature flag to hide Cite provider

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