From: amritsreekumar Date: Sat, 15 Oct 2016 19:15:06 +0000 (+0530) Subject: Add a context to ChangeTags::buildTagFilterSelector X-Git-Tag: 1.31.0-rc.0~4756 X-Git-Url: http://git.cyclocoop.org/%27%40script%40/ecrire/?a=commitdiff_plain;h=db45cfbccd1630ad1960f8359f42a3fbc7ca47df;p=lhc%2Fweb%2Fwiklou.git 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 --- 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() ) ];