Page MenuHomePhabricator

Refactor PHP "global" keyword
Open, Needs TriagePublic

Description

I assume these...

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

image.png (773×1 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.