Page MenuHomePhabricator

Don't use global variables for configs
Open, LowPublic

Description

In gerrit:570042 we introduced a ConfigRegistry for wikispeech and started using Config objects rather than requesting wg globals.

As a result the codebase contains a mixture of global wg... and Config objects. It's desirable to switch over to the later.

Background: https://www.mediawiki.org/wiki/Manual:Configuration_for_developers#Set_configuration_options_using_extension.json_(recommended)

Event Timeline

I recommend against this per T249564.

Thanks for the heads up

We probably still want to unify on either approach but are in no need of doing so until a new recommendation is out.

We use globals in two places. We should use the latest recommendations on the page linked in the description. This is not ConfigRegistry, which we don't use.

Sebastian_Berlin-WMSE renamed this task from Switch to using ConfigRegistry to Don'.Feb 13 2025, 12:06 PM
Sebastian_Berlin-WMSE renamed this task from Don' to Don't use global variables for configs.

So for example, theese two places are in DefaultUserOptions.php and UtteranceStore.php (what I can see):

Instead of:

global $wgUploadDirectory;

We could do:

$this->config->get( 'UploadDirectory' )

?

That should work in UtteranceStore where we have a config. In DefaultUserOptions you have to you have to get it some other way, probably through MediaWikiServices.