jenkins-bot has submitted this change and it was merged. Change subject: Clean up hook usage ......................................................................
Clean up hook usage * Prefix hook handlers with on + hookname. * Remove redundant or unused bool returns. Change-Id: I963afbb61c8873870ca930666e06b49f36002012 --- M WikiLove.hooks.php M extension.json 2 files changed, 20 insertions(+), 40 deletions(-) Approvals: Catrope: Looks good to me, approved jenkins-bot: Verified diff --git a/WikiLove.hooks.php b/WikiLove.hooks.php index 67343bb..f261ec8 100644 --- a/WikiLove.hooks.php +++ b/WikiLove.hooks.php @@ -13,10 +13,8 @@ * LoadExtensionSchemaUpdates hook * * @param DatabaseUpdater $updater - * - * @return bool true */ - public static function loadExtensionSchemaUpdates( $updater = null ) { + public static function onLoadExtensionSchemaUpdates( $updater = null ) { if ( $updater === null ) { global $wgExtNewTables; $wgExtNewTables[] = array( 'wikilove_log', dirname( __FILE__ ) . '/patches/WikiLoveLog.sql' ); @@ -24,17 +22,15 @@ $updater->addExtensionUpdate( array( 'addTable', 'wikilove_log', dirname( __FILE__ ) . '/patches/WikiLoveLog.sql', true ) ); } - return true; } /** * Add the preference in the user preferences with the GetPreferences hook. + * * @param User $user * @param array $preferences - * - * @return bool true */ - public static function getPreferences( $user, &$preferences ) { + public static function onGetPreferences( $user, &$preferences ) { global $wgWikiLoveGlobal; if ( !$wgWikiLoveGlobal ) { $preferences['wikilove-enabled'] = array( @@ -43,7 +39,6 @@ 'label-message' => 'wikilove-enable-preference', ); } - return true; } /** @@ -51,10 +46,8 @@ * * @param OutputPage $out * @param Skin $skin - * - * @return bool true */ - public static function beforePageDisplay( $out, $skin ) { + public static function onBeforePageDisplay( $out, $skin ) { global $wgWikiLoveGlobal; if ( !$wgWikiLoveGlobal && !$out->getUser()->getOption( 'wikilove-enabled' ) ) { @@ -68,17 +61,14 @@ $out->addModuleStyles( 'ext.wikiLove.icon' ); self::$recipient = $title->getBaseText(); } - return true; } /** - * Exports wikilove-recipient and wikilove-anon variables to JS + * Export page/user specific WikiLove variables to JS * * @param array $vars - * - * @return bool true */ - public static function makeGlobalVariablesScript( &$vars ) { + public static function onMakeGlobalVariablesScript( &$vars ) { $vars['wikilove-recipient'] = self::$recipient; $vars['wikilove-anon'] = 0; @@ -86,39 +76,37 @@ $receiver = User::newFromName( self::$recipient ); if ( $receiver === false || $receiver->isAnon() ) $vars['wikilove-anon'] = 1; } - return true; } /** - * Adds a tab or an icon the new way (MediaWiki 1.18+) + * Add a tab or an icon the new way (MediaWiki 1.18+) + * * @param SkinTemplate $skin * @param array $links Navigation links - * @return boolean */ - public static function skinTemplateNavigation( &$skin, &$links ) { + public static function onSkinTemplateNavigation( &$skin, &$links ) { if ( self::showIcon( $skin ) ) { self::skinConfigViewsLinks( $skin, $links['views']); } else { self::skinConfigViewsLinks( $skin, $links['actions']); } - return true; } /** * Configure views links. + * * Helper function for SkinTemplateTabs and SkinTemplateNavigation hooks * to configure views links. * * @param Skin $skin * @param array $views - * @return boolean */ private static function skinConfigViewsLinks( $skin, &$views ) { global $wgWikiLoveGlobal; // If WikiLove is turned off for this user, don't display tab. if ( !$wgWikiLoveGlobal && !$skin->getUser()->getOption( 'wikilove-enabled' ) ) { - return true; + return; } // getUserTalkPage() returns a string on error @@ -132,14 +120,12 @@ $views['wikilove']['primary'] = true; } } - return true; } /** * Only show an icon when the global preference is enabled and the current skin is Vector. * * @param Skin $skin - * * @return boolean */ private static function showIcon( $skin ) { @@ -154,7 +140,6 @@ * * @param Title $title The title of a user page or user talk page * @param User $user the current user - * * @return Title|string Returns either the Title object for the talk page or an error string */ public static function getUserTalkPage( $title, $user ) { @@ -195,31 +180,28 @@ } // Make sure we can edit the page - if ( $talkTitle->quickUserCan( 'edit' ) ) { - return $talkTitle; - } else { + if ( !$talkTitle->quickUserCan( 'edit' ) ) { return wfMessage( 'wikilove-err-cannot-edit' )->plain(); } + + return $talkTitle; } /** * ListDefinedTags and ChangeTagsListActive hook handler + * * @see https://www.mediawiki.org/wiki/Manual:Hooks/ListDefinedTags * @see https://www.mediawiki.org/wiki/Manual:Hooks/ChangeTagsListActive - * * @param array $tags - * @return bool */ public static function onListDefinedTags( &$tags ) { $tags[] = 'wikilove'; - return true; } /** * Tables that Extension:UserMerge needs to update * * @param array $updateFields - * @return bool */ public static function onUserMergeAccountFields( array &$updateFields ) { global $wgWikiLoveLogging; @@ -230,8 +212,6 @@ $updateFields[] = array( 'wikilove_log', 'wll_sender' ); $updateFields[] = array( 'wikilove_log', 'wll_receiver' ); } - - return true; } } diff --git a/extension.json b/extension.json index 87df4c4..f74a079 100644 --- a/extension.json +++ b/extension.json @@ -236,19 +236,19 @@ }, "Hooks": { "GetPreferences": [ - "WikiLoveHooks::getPreferences" + "WikiLoveHooks::onGetPreferences" ], "SkinTemplateNavigation": [ - "WikiLoveHooks::skinTemplateNavigation" + "WikiLoveHooks::onSkinTemplateNavigation" ], "BeforePageDisplay": [ - "WikiLoveHooks::beforePageDisplay" + "WikiLoveHooks::onBeforePageDisplay" ], "LoadExtensionSchemaUpdates": [ - "WikiLoveHooks::loadExtensionSchemaUpdates" + "WikiLoveHooks::onLoadExtensionSchemaUpdates" ], "MakeGlobalVariablesScript": [ - "WikiLoveHooks::makeGlobalVariablesScript" + "WikiLoveHooks::onMakeGlobalVariablesScript" ], "ListDefinedTags": [ "WikiLoveHooks::onListDefinedTags" -- To view, visit https://gerrit.wikimedia.org/r/275918 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I963afbb61c8873870ca930666e06b49f36002012 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/WikiLove Gerrit-Branch: master Gerrit-Owner: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits