From db45cfbccd1630ad1960f8359f42a3fbc7ca47df Mon Sep 17 00:00:00 2001 From: amritsreekumar Date: Sun, 16 Oct 2016 00:45:06 +0530 Subject: [PATCH] Add a context to ChangeTags::buildTagFilterSelector A IContextSource is added as parameter to ChangeTags::buildTagFilterSelector static function, which can be used to avoid the globals. Bug: T105649 Change-Id: I50ca27c75b4807f5e4391648bfd5cac9169517e9 --- includes/changetags/ChangeTags.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php index e3035be630..bfabd51bcc 100644 --- a/includes/changetags/ChangeTags.php +++ b/includes/changetags/ChangeTags.php @@ -668,12 +668,20 @@ class ChangeTags { * @param string $selected Tag to select by default * @param bool $ooui Use an OOUI TextInputWidget as selector instead of a non-OOUI input field * You need to call OutputPage::enableOOUI() yourself. + * @param IContextSource|null $context + * @note Even though it takes null as a valid argument, an IContextSource is preferred + * in a new code, as the null value can change in the future * @return array an array of (label, selector) */ - public static function buildTagFilterSelector( $selected = '', $ooui = false ) { - global $wgUseTagFilter; + public static function buildTagFilterSelector( + $selected = '', $ooui = false, IContextSource $context = null + ) { + if ( !$context ) { + $context = RequestContext::getMain(); + } - if ( !$wgUseTagFilter || !count( self::listDefinedTags() ) ) { + $config = $context->getConfig(); + if ( !$config->get( 'UseTagFilter' ) || !count( self::listDefinedTags() ) ) { return []; } @@ -681,7 +689,7 @@ class ChangeTags { Html::rawElement( 'label', [ 'for' => 'tagfilter' ], - wfMessage( 'tag-filter' )->parse() + $context->msg( 'tag-filter' )->parse() ) ]; -- 2.20.1