Legoktm has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/341493 )

Change subject: Move conditional special page registration to a hook
......................................................................

Move conditional special page registration to a hook

Use the SpecialPage_initList hook for conditionally registering special
pages since extension functions can run too late depending on what other
extensions are installed.

Bug: T132454
Change-Id: I061bace88d9ce30c8f0799b405357bb579723442
---
M extension.json
M frontend/MWOAuthUI.hooks.php
M frontend/MWOAuthUI.setup.php
3 files changed, 13 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OAuth 
refs/changes/93/341493/1

diff --git a/extension.json b/extension.json
index 9332b69..fcde189 100644
--- a/extension.json
+++ b/extension.json
@@ -134,7 +134,8 @@
                "CentralAuthAbortCentralAuthToken": 
"MediaWiki\\Extensions\\OAuth\\MWOAuthAPISetup::onCentralAuthAbortCentralAuthToken",
                "TestCanonicalRedirect": 
"MediaWiki\\Extensions\\OAuth\\MWOAuthAPISetup::onTestCanonicalRedirect",
                "SetupAfterCache": 
"MediaWiki\\Extensions\\OAuth\\MWOAuthHooks::onSetupAfterCache",
-               "ApiRsdServiceApis": 
"MediaWiki\\Extensions\\OAuth\\MWOAuthHooks::onApiRsdServiceApis"
+               "ApiRsdServiceApis": 
"MediaWiki\\Extensions\\OAuth\\MWOAuthHooks::onApiRsdServiceApis",
+               "SpecialPage_initList": 
"MediaWiki\\Extensions\\OAuth\\MWOAuthUIHooks::onSpecialPage_initList"
        },
        "config": {
                "MWOAuthCentralWiki": {
diff --git a/frontend/MWOAuthUI.hooks.php b/frontend/MWOAuthUI.hooks.php
index 2c2d9c9..1202351 100644
--- a/frontend/MWOAuthUI.hooks.php
+++ b/frontend/MWOAuthUI.hooks.php
@@ -205,4 +205,14 @@
 
                $icons['oauth'] = [ 'path' => 
'OAuth/frontend/assets/echo-icon.png' ];
        }
+
+       /**
+        * @param array $specialPages
+        */
+       public static function onSpecialPage_initList( array &$specialPages ) {
+               if ( MWOAuthUtils::isCentralWiki() ) {
+                       $specialPages['OAuthConsumerRegistration'] = 
SpecialMWOAuthConsumerRegistration::class;
+                       $specialPages['OAuthManageConsumers'] = 
SpecialMWOAuthManageConsumers::class;
+               }
+       }
 }
diff --git a/frontend/MWOAuthUI.setup.php b/frontend/MWOAuthUI.setup.php
index ff092e4..14e068f 100644
--- a/frontend/MWOAuthUI.setup.php
+++ b/frontend/MWOAuthUI.setup.php
@@ -10,13 +10,10 @@
         * @return void
         */
        public static function conditionalSetup() {
-               global $wgSpecialPages, $wgLogTypes, $wgLogNames,
+               global $wgLogTypes, $wgLogNames,
                        $wgLogHeaders, $wgLogActionsHandlers;
 
                if ( MWOAuthUtils::isCentralWiki() ) {
-                       $wgSpecialPages['OAuthConsumerRegistration'] = 
'MediaWiki\Extensions\OAuth\SpecialMWOAuthConsumerRegistration';
-                       $wgSpecialPages['OAuthManageConsumers'] = 
'MediaWiki\Extensions\OAuth\SpecialMWOAuthManageConsumers';
-
                        $wgLogTypes[] = 'mwoauthconsumer';
                        $wgLogNames['mwoauthconsumer'] = 
'mwoauthconsumer-consumer-logpage';
                        $wgLogHeaders['mwoauthconsumer'] = 
'mwoauthconsumer-consumer-logpagetext';

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I061bace88d9ce30c8f0799b405357bb579723442
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OAuth
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