Page MenuHomePhabricator

Refactor PHP "global" keyword
Open, Needs TriagePublic

Description

I assume these...

private static function shouldNoIndexForNewArticleReasons( WikiPage $page ) {
	global $wgPageTriageNoIndexUnreviewedNewArticles, $wgPageTriageMaxAge;

image.png (1,012×773 px, 101 KB)

Should be changed to something like...

$config = MediaWikiServices::getInstance()->getMainConfig();
$pageTriageDraftNamespaceId = $config->get( 'PageTriageDraftNamespaceId' );

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

@Novem_Linguae yeah that would be good. Even better would be to pass Config $config to the static method (or pass e.g. int $PageTriageMaxAge). Ideally the method is passed whatever it needs to do its work, rather than "reaching outside" (e.g. invoke the service to get the config object); that tends to help with readability & makes testing easier as well.

Change #1329330 had a related patch set uploaded (by D3r1ck01; author: Derick Alangi):

[mediawiki/extensions/PageTriage@master] [Cleanup] Avoid the usage of globals and use MainConfig object

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

Change #1329330 merged by jenkins-bot:

[mediawiki/extensions/PageTriage@master] [Cleanup] Avoid the usage of globals and use MainConfig object

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