From 292f21fc383b332527076082fae6761b68a1e63b Mon Sep 17 00:00:00 2001 From: Fomafix Date: Thu, 5 Oct 2023 09:51:58 +0000 Subject: [PATCH] Get parameters from config instead of global variable in getDataForJs() Change-Id: Ie01fa1181f6c0878686f056e0a70f89766c090e6 --- includes/Hooks.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/Hooks.php b/includes/Hooks.php index 5ce9b701..c9b2ad11 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -36,6 +36,7 @@ use MediaWiki\Html\Html; use MediaWiki\Linker\LinkTarget; use MediaWiki\Output\OutputPage; use MediaWiki\Parser\Sanitizer; +use MediaWiki\ResourceLoader as RL; use MediaWiki\SpecialPage\SpecialPage; use MediaWiki\Title\Title; use Parser; @@ -236,13 +237,13 @@ class Hooks implements * Get exported data for the "ext.categoryTree" ResourceLoader module. * * @internal For use in extension.json only. + * @param RL\Context $context + * @param Config $config * @return array Data to be serialised as data.json */ - public static function getDataForJs() { - global $wgCategoryTreeCategoryPageOptions; - + public static function getDataForJs( RL\Context $context, Config $config ) { // Look, this is pretty bad but CategoryTree is just whacky, it needs to be rewritten - $ct = new CategoryTree( $wgCategoryTreeCategoryPageOptions ); + $ct = new CategoryTree( $config->get( 'CategoryTreeCategoryPageOptions' ) ); return [ 'defaultCtOptions' => $ct->getOptionsAsJsStructure(),