Parent5446 has uploaded a new change for review. https://gerrit.wikimedia.org/r/213324
Change subject: Made hooks register unconditionally ...................................................................... Made hooks register unconditionally Rather than have a function that registers the hook depending on a config variable, have the hook always registered, and just add a check in the hook itself. Change-Id: Ida3d4543a8184900e8b1b3623fdfd99acdcab13f --- M CleanChanges.php M Filters.php 2 files changed, 33 insertions(+), 21 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CleanChanges refs/changes/24/213324/1 diff --git a/CleanChanges.php b/CleanChanges.php index 414bccd..0f4c7cf 100644 --- a/CleanChanges.php +++ b/CleanChanges.php @@ -23,6 +23,11 @@ /* Hook into code */ $wgHooks['FetchChangesList'][] = 'NCL::hook'; $wgHooks['MakeGlobalVariablesScript'][] = 'NCL::addScriptVariables'; +$wgHooks['SpecialRecentChangesQuery'][] = 'CCFilters::user'; +$wgHooks['SpecialRecentChangesPanel'][] = 'CCFilters::userForm'; +$wgHooks['SpecialRecentChangesQuery'][] = 'CCFilters::trailer'; +$wgHooks['SpecialRecentChangesPanel'][] = 'CCFilters::trailerForm'; + /* Extension information */ $wgExtensionCredits['other'][] = array( @@ -40,16 +45,3 @@ $wgExtensionFunctions[] = 'ccSetupFilters'; $wgAutoloadClasses['CCFilters'] = "$dir/Filters.php"; - -function ccSetupFilters() { - global $wgCCUserFilter, $wgCCTrailerFilter, $wgHooks; - - if ( $wgCCUserFilter ) { - $wgHooks['SpecialRecentChangesQuery'][] = 'CCFilters::user'; - $wgHooks['SpecialRecentChangesPanel'][] = 'CCFilters::userForm'; - } - if ( $wgCCTrailerFilter ) { - $wgHooks['SpecialRecentChangesQuery'][] = 'CCFilters::trailer'; - $wgHooks['SpecialRecentChangesPanel'][] = 'CCFilters::trailerForm'; - } -} diff --git a/Filters.php b/Filters.php index d6e9939..13e0858 100644 --- a/Filters.php +++ b/Filters.php @@ -10,7 +10,12 @@ * @return bool */ public static function user( &$conds, &$tables, &$join_conds, FormOptions $opts ) { - global $wgRequest; + global $wgRequest, $wgCCUserFilter; + + if ( !$wgCCUserFilter ) { + return true; + } + $opts->add( 'users', '' ); $users = $wgRequest->getVal( 'users' ); if ( $users === null ) { @@ -40,8 +45,13 @@ * @return bool */ public static function userForm( &$items, FormOptions $opts ) { + global $wgRequest, $wgCCUserFilter; + + if ( !$wgCCUserFilter ) { + return true; + } + $opts->consumeValue( 'users' ); - global $wgRequest; $default = $wgRequest->getVal( 'users', '' ); $items['users'] = Xml::inputLabelSep( wfMessage( 'cleanchanges-users' )->text(), 'users', @@ -57,7 +67,12 @@ * @return bool */ public static function trailer( &$conds, &$tables, &$join_conds, FormOptions $opts ) { - global $wgRequest; + global $wgRequest, $wgCCTrailerFilter; + + if ( !$wgCCTrailerFilter ) { + return true; + } + $opts->add( 'trailer', '' ); $trailer = $wgRequest->getVal( 'trailer' ); if ( $trailer === null ) return true; @@ -75,14 +90,19 @@ * @return bool */ public static function trailerForm( &$items, FormOptions $opts ) { - $opts->consumeValue( 'trailer' ); - - global $wgRequest; - $default = $wgRequest->getVal( 'trailer', '' ); /** * @var Language $wgLang */ - global $wgLang; + global $wgLang, $wgRequest, $wgCCTrailerFilter; + + if ( !$wgCCTrailerFilter ) { + return true; + } + + $opts->consumeValue( 'trailer' ); + + $default = $wgRequest->getVal( 'trailer', '' ); + if ( is_callable( array( 'LanguageNames', 'getNames' ) ) ) { $languages = LanguageNames::getNames( $wgLang->getCode(), LanguageNames::FALLBACK_NORMAL, -- To view, visit https://gerrit.wikimedia.org/r/213324 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ida3d4543a8184900e8b1b3623fdfd99acdcab13f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CleanChanges Gerrit-Branch: master Gerrit-Owner: Parent5446 <tylerro...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits