[MediaWiki-commits] [Gerrit] Clean up hook usage - change (mediawiki...WikiLove)
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
[MediaWiki-commits] [Gerrit] Clean up hook usage - change (mediawiki...WikiLove)
Krinkle has uploaded a new change for review. https://gerrit.wikimedia.org/r/275918 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, 21 insertions(+), 42 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikiLove refs/changes/18/275918/1 diff --git a/WikiLove.hooks.php b/WikiLove.hooks.php index 67343bb..34e91ba 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,57 +61,51 @@ $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 ) { - $vars['wikilove-recipient'] = self::$recipient; - + public static function onMakeGlobalVariablesScript( &$vars ) { $vars['wikilove-anon'] = 0; + if ( self::$recipient !== '' ) { $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;