Happy5214 has uploaded a new change for review. https://gerrit.wikimedia.org/r/220978
Change subject: Make inclusion of API action=flowthank conditional on Flow being installed ...................................................................... Make inclusion of API action=flowthank conditional on Flow being installed This patch will only enable the API module 'flowthank' if Flow is installed, instead of checking whether Flow is installed when the module is invoked. Bug: T85521 Change-Id: I0183188dd17f035f3c89e40a9cb1a21421071aca --- M ApiFlowThank.php M Thanks.hooks.php M Thanks.php 3 files changed, 15 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Thanks refs/changes/78/220978/1 diff --git a/ApiFlowThank.php b/ApiFlowThank.php index 174c313..1fefc0e 100644 --- a/ApiFlowThank.php +++ b/ApiFlowThank.php @@ -17,7 +17,6 @@ class ApiFlowThank extends ApiThank { public function execute() { - $this->dieIfFlowNotInstalled(); $this->dieIfEchoNotInstalled(); $user = $this->getUser(); @@ -56,12 +55,6 @@ $topicTitleText, $pageTitle ); - } - - private function dieIfFlowNotInstalled() { - if ( !class_exists( 'FlowHooks' ) ) { - $this->dieUsage( 'Flow is not installed on this wiki', 'flownotinstalled' ); - } } private function userAlreadySentThanksForId( User $user, UUID $id ) { diff --git a/Thanks.hooks.php b/Thanks.hooks.php index 4119ade..ee73d77 100644 --- a/Thanks.hooks.php +++ b/Thanks.hooks.php @@ -299,4 +299,16 @@ } return true; } + + /** + * Initialize Thanks extension. Invoked from $wgExtensionFunctions. + */ + public static function initThanksExtension() { + global $wgAPIModules; + + // Load 'flowthank' API module only if Flow is installed + if ( class_exists( 'FlowHooks' ) ) { + $wgAPIModules['flowthank'] = 'ApiFlowThank'; + } + } } diff --git a/Thanks.php b/Thanks.php index 014e556..f3a735e 100644 --- a/Thanks.php +++ b/Thanks.php @@ -56,8 +56,6 @@ // Register APIs $wgAPIModules['thank'] = 'ApiRevThank'; -/** @todo This should be conditional on Flow being installed on the wiki */ -$wgAPIModules['flowthank'] = 'ApiFlowThank'; // Register special page $wgSpecialPages['Thanks'] = 'SpecialThanks'; @@ -76,6 +74,9 @@ $wgHooks['BeforePageDisplay'][] = 'ThanksHooks::onBeforePageDisplay'; $wgHooks['ResourceLoaderTestModules'][] = 'ThanksHooks::onResourceLoaderTestModules'; +// Extension initialization +$wgExtensionFunctions[] = 'ThanksHooks::initThanksExtension'; + // Register modules $wgResourceModules['ext.thanks'] = array( 'scripts' => array( -- To view, visit https://gerrit.wikimedia.org/r/220978 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0183188dd17f035f3c89e40a9cb1a21421071aca Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Thanks Gerrit-Branch: master Gerrit-Owner: Happy5214 <happy5...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits