Page MenuHomePhabricator

remove configuration access via global variables in core
Open, MediumPublic

Description

Configuration variables should never be accessed as global variables. Ideally, configuration is injected, individually or via a ServiceOptions instance or as a Config object. Where injection is not currently possible, configuration needs to be accessed via the main Config object obtained from the global service container: MediaWikiServices::getInstance()->getMainConfig()->get( 'SomeOption' ).

Related Objects

StatusSubtypeAssignedTask
OpenNone
OpenNone
OpenFeatureNone
OpenFeatureNone
OpenNone
OpenNone
Resolved Tgr
ResolvedAnomie
ResolvedJoe
ResolvedJoe
Resolvedhashar
Resolvedbd808
ResolvedAnomie
ResolvedKrinkle
ResolvedNone
ResolvedJanZerebecki
ResolvedKrinkle
Resolved Tgr
ResolvedxSavitar
OpenNone
ResolvedTchanders
ResolvedNone
ResolvedFlorian
ResolvedFlorian
ResolvedNone
OpenFeatureNone
OpenNone
OpenNone
OpenSimetrical

Event Timeline

Forgot to link the patch that replaces most of the easily replaceable ones. T297797 lists places where it wasn't easily removable.

daniel moved this task from Doing to Todo on the MediaWiki-SettingsBuilder board.
daniel added a subscriber: tchin.

Status: Thomas' patch addressed many places where global variables were used to access configuration variables, but there are still quite a few left. Most of the remaining cases either write to the global variable, or the code is executed in a phpunit data provider, which causes any access to the MediawikiServices singleton to trigger warnings.

Change 753991 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] SettingsBuilder: allow maintenance scripts to manipulate config

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

daniel triaged this task as Medium priority.Jan 26 2022, 12:11 PM

Change 753991 merged by jenkins-bot:

[mediawiki/core@master] SettingsBuilder: allow maintenance scripts to manipulate config

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

Change 757960 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] Remove access to config globals from includes/debug/logger

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

Change 757961 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] Remove access to config globals from includes/exception

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

Change 757963 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] remove access to config globals from includes/parser

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

Change 757965 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] remove access to config globals from Title

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

Change 757966 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] remove access to config globals from FauxResponse

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

Change 757967 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] remove access to config globals from more classes

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

Change 757966 merged by jenkins-bot:

[mediawiki/core@master] remove access to config globals from FauxResponse

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

Change 757963 merged by jenkins-bot:

[mediawiki/core@master] remove access to config globals from includes/parser

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

Change 763956 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] Pass SettingsBuilder into config callbacks.

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

Change 764448 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] Split default variable initialization out of Setup.php

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

Change 763956 merged by jenkins-bot:

[mediawiki/core@master] Pass SettingsBuilder into config callbacks.

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

Change 764448 abandoned by Simetrical:

[mediawiki/core@master] Split default variable initialization out of Setup.php

Reason:

This was landed elsewhere: I931b92357ec48db4665891c8546f86264885e881

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

Change 787531 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/FileImporter@master] Replace MediaWikiTitleCodec with TitleParser mock

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

Change 787531 merged by jenkins-bot:

[mediawiki/extensions/FileImporter@master] Replace MediaWikiTitleCodec with TitleParser mock

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

Change 757967 merged by jenkins-bot:

[mediawiki/core@master] Remove access to config globals from more classes

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

Change 787798 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/core@master] config: Do not get wgInitialSessionId and wgCommandLineMode from config

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

Change 757961 merged by jenkins-bot:

[mediawiki/core@master] Remove access to config globals from includes/exception

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

Change 806436 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] PHPUnit: introduce overrideConfigValues.

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

Change 806436 merged by jenkins-bot:

[mediawiki/core@master] PHPUnit: introduce overrideConfigValues.

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