Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/179961

Change subject: Don't conditionally register hooks
......................................................................

Don't conditionally register hooks

ExtensionFunctions are called whenever MediaWiki is initialized, but
the hooks will only be called whenever neccessary, so move the
conditionals (whether CentralAuth exists) into the hook function
itself.

Change-Id: Id61b9f57a71a4a7c7d06d6967826eaafabd31b40
---
M GettingStarted.php
M Hooks.php
2 files changed, 6 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GettingStarted 
refs/changes/61/179961/1

diff --git a/GettingStarted.php b/GettingStarted.php
index 392926a..f940d42 100644
--- a/GettingStarted.php
+++ b/GettingStarted.php
@@ -368,11 +368,12 @@
 $wgHooks[ 'ArticleDeleteComplete' ][] = 
'GettingStarted\RedisCategorySync::onArticleDeleteComplete';
 $wgHooks[ 'MakeGlobalVariablesScript' ][] = 
'GettingStarted\Hooks::onMakeGlobalVariablesScript';
 $wgHooks[ 'ResourceLoaderGetConfigVars' ][] = 
'GettingStarted\Hooks::onResourceLoaderGetConfigVars';
+$wgHooks[ 'CentralAuthPostLoginRedirect' ][] = 
'GettingStarted\Hooks::onCentralAuthPostLoginRedirect';
+$wgHooks[ 'PostLoginRedirect' ][] = 
'GettingStarted\Hooks::onPostLoginRedirect';
 $wgHooks[ 'GetPreferences' ][] = 'GettingStarted\Hooks::onGetPreferences';
 $wgHooks[ 'UserLogoutComplete'][] = 
'GettingStarted\Hooks::onUserLogoutComplete';
 $wgHooks[ 'PersonalUrls' ][] = 'GettingStarted\Hooks::onPersonalUrls';
 $wgHooks[ 'UnitTestsList' ][] = 'GettingStarted\Hooks::onUnitTestsList';
-$wgExtensionFunctions[] = 'GettingStarted\Hooks::onSetup';
 
 list( $site, $lang ) = $wgConf->siteFromDB( $wgDBname );
 
diff --git a/Hooks.php b/Hooks.php
index b096e51..7ce0ea2 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -13,21 +13,6 @@
 
 class Hooks {
        /**
-        * Determine which post login hook to register and register it
-        * This allows GettingStarted to work with or without CentralAuth
-        * See Bug: 65619
-        */
-       public static function onSetup() {
-               global $wgHooks;
-               $isCentralAuthAvailable = class_exists( 'SpecialCentralLogin' );
-               if( $isCentralAuthAvailable ) {
-                       $wgHooks[ 'CentralAuthPostLoginRedirect' ][] = 
'GettingStarted\Hooks::onCentralAuthPostLoginRedirect';
-               } else {
-                       $wgHooks[ 'PostLoginRedirect' ][] = 
'GettingStarted\Hooks::onPostLoginRedirect';
-               }
-       }
-
-       /**
         * Deserialized vesion of the openTask data structure.
         * Initialized as needed.
         *
@@ -355,6 +340,10 @@
         * @param string $type login redirect condition
         */
        public static function onPostLoginRedirect( &$returnTo, 
&$returnToQuery, &$type ) {
+               if ( class_exists( 'SpecialCentralLogin' ) ) {
+                       // Will be handled by the CentralAuthPostLoginRedirect 
hook
+                       return true;
+               }
                // Abort if we should not show getting started
                if ( !self::shouldShowGettingStarted( $returnToQuery, $type ) ) 
{
                        return true;

-- 
To view, visit https://gerrit.wikimedia.org/r/179961
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id61b9f57a71a4a7c7d06d6967826eaafabd31b40
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GettingStarted
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to