Merge "Remove "return true" legacy behavior from hook handler functions"

This commit is contained in:
jenkins-bot 2019-02-02 22:37:26 +00:00 committed by Gerrit Code Review
commit 748d25237e

View file

@ -56,7 +56,6 @@ class VisualEditorHooks {
* *
* @param OutputPage &$output The page view. * @param OutputPage &$output The page view.
* @param Skin &$skin The skin that's going to build the UI. * @param Skin &$skin The skin that's going to build the UI.
* @return bool Always true.
*/ */
public static function onBeforePageDisplay( OutputPage &$output, Skin &$skin ) { public static function onBeforePageDisplay( OutputPage &$output, Skin &$skin ) {
$output->addModules( [ $output->addModules( [
@ -79,7 +78,6 @@ class VisualEditorHooks {
'wgEditSubmitButtonLabelPublish', 'wgEditSubmitButtonLabelPublish',
$veConfig->get( 'EditSubmitButtonLabelPublish' ) $veConfig->get( 'EditSubmitButtonLabelPublish' )
); );
return true;
} }
/** /**
@ -336,14 +334,13 @@ class VisualEditorHooks {
* *
* @param SkinTemplate &$skin The skin template on which the UI is built. * @param SkinTemplate &$skin The skin template on which the UI is built.
* @param array &$links Navigation links. * @param array &$links Navigation links.
* @return bool Always true.
*/ */
public static function onSkinTemplateNavigation( SkinTemplate &$skin, array &$links ) { public static function onSkinTemplateNavigation( SkinTemplate &$skin, array &$links ) {
$config = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' ); $config = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
// Exit if there's no edit link for whatever reason (e.g. protected page) // Exit if there's no edit link for whatever reason (e.g. protected page)
if ( !isset( $links['views']['edit'] ) ) { if ( !isset( $links['views']['edit'] ) ) {
return true; return;
} }
$user = $skin->getUser(); $user = $skin->getUser();
@ -351,7 +348,7 @@ class VisualEditorHooks {
$config->get( 'VisualEditorUseSingleEditTab' ) && $config->get( 'VisualEditorUseSingleEditTab' ) &&
$user->getOption( 'visualeditor-tabs' ) === 'prefer-wt' $user->getOption( 'visualeditor-tabs' ) === 'prefer-wt'
) { ) {
return true; return;
} }
if ( if (
@ -394,7 +391,7 @@ class VisualEditorHooks {
$user->getOption( 'visualeditor-autodisable' ) || $user->getOption( 'visualeditor-autodisable' ) ||
( $config->get( 'VisualEditorDisableForAnons' ) && $user->isAnon() ) ( $config->get( 'VisualEditorDisableForAnons' ) && $user->isAnon() )
) { ) {
return true; return;
} }
$title = $skin->getRelevantTitle(); $title = $skin->getRelevantTitle();
@ -500,7 +497,6 @@ class VisualEditorHooks {
} }
} }
$links['views'] = $newViews; $links['views'] = $newViews;
return true;
} }
/** /**
@ -509,14 +505,12 @@ class VisualEditorHooks {
* *
* @param EditPage $editPage The edit page view. * @param EditPage $editPage The edit page view.
* @param OutputPage $output The page view. * @param OutputPage $output The page view.
* @return bool Always true.
*/ */
public static function onEditPageShowEditFormFields( EditPage $editPage, OutputPage $output ) { public static function onEditPageShowEditFormFields( EditPage $editPage, OutputPage $output ) {
$request = $output->getRequest(); $request = $output->getRequest();
if ( $request->getBool( 'veswitched' ) ) { if ( $request->getBool( 'veswitched' ) ) {
$output->addHTML( Html::hidden( 'veswitched', '1' ) ); $output->addHTML( Html::hidden( 'veswitched', '1' ) );
} }
return true;
} }
/** /**
@ -524,14 +518,12 @@ class VisualEditorHooks {
* Adds 'visualeditor-switched' tag to the edit if requested * Adds 'visualeditor-switched' tag to the edit if requested
* *
* @param RecentChange $rc The new RC entry. * @param RecentChange $rc The new RC entry.
* @return bool Always true.
*/ */
public static function onRecentChangeSave( RecentChange $rc ) { public static function onRecentChangeSave( RecentChange $rc ) {
$request = RequestContext::getMain()->getRequest(); $request = RequestContext::getMain()->getRequest();
if ( $request->getBool( 'veswitched' ) && $rc->getAttribute( 'rc_this_oldid' ) ) { if ( $request->getBool( 'veswitched' ) && $rc->getAttribute( 'rc_this_oldid' ) ) {
$rc->addTags( 'visualeditor-switched' ); $rc->addTags( 'visualeditor-switched' );
} }
return true;
} }
/** /**
@ -545,7 +537,6 @@ class VisualEditorHooks {
* @param string $tooltip The default tooltip. * @param string $tooltip The default tooltip.
* @param array &$result All link detail arrays. * @param array &$result All link detail arrays.
* @param Language $lang The user interface language. * @param Language $lang The user interface language.
* @return bool Always true.
*/ */
public static function onSkinEditSectionLinks( Skin $skin, Title $title, $section, public static function onSkinEditSectionLinks( Skin $skin, Title $title, $section,
$tooltip, &$result, $lang $tooltip, &$result, $lang
@ -554,7 +545,7 @@ class VisualEditorHooks {
// Exit if we're in parserTests // Exit if we're in parserTests
if ( isset( $GLOBALS[ 'wgVisualEditorInParserTests' ] ) ) { if ( isset( $GLOBALS[ 'wgVisualEditorInParserTests' ] ) ) {
return true; return;
} }
$user = $skin->getUser(); $user = $skin->getUser();
@ -565,7 +556,7 @@ class VisualEditorHooks {
$user->getOption( 'visualeditor-autodisable' ) || $user->getOption( 'visualeditor-autodisable' ) ||
( $config->get( 'VisualEditorDisableForAnons' ) && $user->isAnon() ) ( $config->get( 'VisualEditorDisableForAnons' ) && $user->isAnon() )
) { ) {
return true; return;
} }
// Exit if we're on a foreign file description page // Exit if we're on a foreign file description page
@ -574,7 +565,7 @@ class VisualEditorHooks {
WikiPage::factory( $title ) instanceof WikiFilePage && WikiPage::factory( $title ) instanceof WikiFilePage &&
!WikiPage::factory( $title )->isLocal() !WikiPage::factory( $title )->isLocal()
) { ) {
return true; return;
} }
$editor = self::getLastEditor( $user, RequestContext::getMain()->getRequest() ); $editor = self::getLastEditor( $user, RequestContext::getMain()->getRequest() );
@ -597,7 +588,7 @@ class VisualEditorHooks {
$config->get( 'VisualEditorUseSingleEditTab' ) && $config->get( 'VisualEditorUseSingleEditTab' ) &&
$user->getOption( 'visualeditor-tabs' ) !== 'multi-tab' $user->getOption( 'visualeditor-tabs' ) !== 'multi-tab'
) { ) {
return true; return;
} }
// add VE edit section in VE available namespaces // add VE edit section in VE available namespaces
@ -621,7 +612,6 @@ class VisualEditorHooks {
// ... wfArrayInsertBefore? // ... wfArrayInsertBefore?
} }
} }
return true;
} }
/** /**
@ -644,7 +634,6 @@ class VisualEditorHooks {
* *
* @param User $user The user object * @param User $user The user object
* @param array &$preferences Their preferences object * @param array &$preferences Their preferences object
* @return bool Always true
*/ */
public static function onGetPreferences( User $user, array &$preferences ) { public static function onGetPreferences( User $user, array &$preferences ) {
global $wgLang; global $wgLang;
@ -730,7 +719,6 @@ class VisualEditorHooks {
$preferences['visualeditor-findAndReplace-regex'] = $api; $preferences['visualeditor-findAndReplace-regex'] = $api;
$preferences['visualeditor-findAndReplace-matchCase'] = $api; $preferences['visualeditor-findAndReplace-matchCase'] = $api;
$preferences['visualeditor-findAndReplace-word'] = $api; $preferences['visualeditor-findAndReplace-word'] = $api;
return true;
} }
/** /**
@ -843,7 +831,6 @@ class VisualEditorHooks {
* core Special:Tags with the change tags in use by VisualEditor. * core Special:Tags with the change tags in use by VisualEditor.
* *
* @param array &$tags Available change tags. * @param array &$tags Available change tags.
* @return bool Always true.
*/ */
public static function onListDefinedTags( &$tags ) { public static function onListDefinedTags( &$tags ) {
$tags[] = 'visualeditor'; $tags[] = 'visualeditor';
@ -851,7 +838,6 @@ class VisualEditorHooks {
$tags[] = 'visualeditor-needcheck'; $tags[] = 'visualeditor-needcheck';
$tags[] = 'visualeditor-switched'; $tags[] = 'visualeditor-switched';
$tags[] = 'visualeditor-wikitext'; $tags[] = 'visualeditor-wikitext';
return true;
} }
/** /**
@ -859,7 +845,6 @@ class VisualEditorHooks {
* *
* @param array &$vars Global variables object * @param array &$vars Global variables object
* @param OutputPage $out The page view. * @param OutputPage $out The page view.
* @return bool Always true
*/ */
public static function onMakeGlobalVariablesScript( array &$vars, OutputPage $out ) { public static function onMakeGlobalVariablesScript( array &$vars, OutputPage $out ) {
$pageLanguage = ApiVisualEditor::getPageLanguage( $out->getTitle() ); $pageLanguage = ApiVisualEditor::getPageLanguage( $out->getTitle() );
@ -875,15 +860,12 @@ class VisualEditorHooks {
'usePageImages' => ExtensionRegistry::getInstance()->isLoaded( 'PageImages' ), 'usePageImages' => ExtensionRegistry::getInstance()->isLoaded( 'PageImages' ),
'usePageDescriptions' => defined( 'WBC_VERSION' ), 'usePageDescriptions' => defined( 'WBC_VERSION' ),
]; ];
return true;
} }
/** /**
* Adds extra variables to the global config * Adds extra variables to the global config
* *
* @param array &$vars Global variables object * @param array &$vars Global variables object
* @return bool Always true
*/ */
public static function onResourceLoaderGetConfigVars( array &$vars ) { public static function onResourceLoaderGetConfigVars( array &$vars ) {
$coreConfig = RequestContext::getMain()->getConfig(); $coreConfig = RequestContext::getMain()->getConfig();
@ -934,8 +916,6 @@ class VisualEditorHooks {
'sourceFeedbackTitle' => $veConfig->get( 'VisualEditorSourceFeedbackTitle' ), 'sourceFeedbackTitle' => $veConfig->get( 'VisualEditorSourceFeedbackTitle' ),
'enableBlockNoticeStats' => $coreConfig->get( 'EnableBlockNoticeStats' ), 'enableBlockNoticeStats' => $coreConfig->get( 'EnableBlockNoticeStats' ),
]; ];
return true;
} }
/** /**
@ -943,7 +923,6 @@ class VisualEditorHooks {
* been registered by the UniversalLanguageSelector extension or the TemplateData extension. * been registered by the UniversalLanguageSelector extension or the TemplateData extension.
* *
* @param ResourceLoader &$resourceLoader Client-side code and assets to be loaded. * @param ResourceLoader &$resourceLoader Client-side code and assets to be loaded.
* @return bool Always true.
*/ */
public static function onResourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) { public static function onResourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) {
$resourceModules = $resourceLoader->getConfig()->get( 'ResourceModules' ); $resourceModules = $resourceLoader->getConfig()->get( 'ResourceModules' );
@ -989,8 +968,6 @@ class VisualEditorHooks {
'targets' => [ 'desktop', 'mobile' ], 'targets' => [ 'desktop', 'mobile' ],
] ]
] ); ] );
return true;
} }
/** /**
@ -998,7 +975,6 @@ class VisualEditorHooks {
* *
* @param array &$testModules The ResourceLoader test modules array * @param array &$testModules The ResourceLoader test modules array
* @param ResourceLoader &$resourceLoader The ResourceLoader controller * @param ResourceLoader &$resourceLoader The ResourceLoader controller
* @return bool Always true
*/ */
public static function onResourceLoaderTestModules( public static function onResourceLoaderTestModules(
array &$testModules, array &$testModules,
@ -1185,8 +1161,6 @@ class VisualEditorHooks {
'localBasePath' => dirname( __DIR__ ), 'localBasePath' => dirname( __DIR__ ),
'remoteExtPath' => 'VisualEditor', 'remoteExtPath' => 'VisualEditor',
]; ];
return true;
} }
/** /**
@ -1201,12 +1175,9 @@ class VisualEditorHooks {
/** /**
* @param array &$redirectParams Parameters preserved on special page redirects * @param array &$redirectParams Parameters preserved on special page redirects
* to wiki pages * to wiki pages
* @return bool Always true
*/ */
public static function onRedirectSpecialArticleRedirectParams( &$redirectParams ) { public static function onRedirectSpecialArticleRedirectParams( &$redirectParams ) {
array_push( $redirectParams, 'veaction' ); array_push( $redirectParams, 'veaction' );
return true;
} }
/** /**
@ -1218,7 +1189,6 @@ class VisualEditorHooks {
* @param User $user The user-specific settings. * @param User $user The user-specific settings.
* @param WebRequest $request The request. * @param WebRequest $request The request.
* @param MediaWiki $mediaWiki Helper class. * @param MediaWiki $mediaWiki Helper class.
* @return bool Always true
*/ */
public static function onBeforeInitialize( public static function onBeforeInitialize(
Title $title, $article, OutputPage $output, Title $title, $article, OutputPage $output,
@ -1227,7 +1197,6 @@ class VisualEditorHooks {
if ( $request->getVal( 'veaction' ) ) { if ( $request->getVal( 'veaction' ) ) {
$request->setVal( 'redirect', 'no' ); $request->setVal( 'redirect', 'no' );
} }
return true;
} }
/** /**
@ -1246,7 +1215,6 @@ class VisualEditorHooks {
* *
* @param User $user The user-specific settings. * @param User $user The user-specific settings.
* @param bool $autocreated True if the user was auto-created (not a new global user). * @param bool $autocreated True if the user was auto-created (not a new global user).
* @return bool Always true
*/ */
public static function onLocalUserCreated( $user, $autocreated ) { public static function onLocalUserCreated( $user, $autocreated ) {
$config = RequestContext::getMain()->getConfig(); $config = RequestContext::getMain()->getConfig();
@ -1275,15 +1243,12 @@ class VisualEditorHooks {
$user->setOption( 'visualeditor-enable', 1 ); $user->setOption( 'visualeditor-enable', 1 );
$user->saveSettings(); $user->saveSettings();
} }
return true;
} }
/** /**
* On login, if user has a VEE cookie, set their preference equal to it. * On login, if user has a VEE cookie, set their preference equal to it.
* *
* @param User $user The user-specific settings. * @param User $user The user-specific settings.
* @return bool Always true.
*/ */
public static function onUserLoggedIn( $user ) { public static function onUserLoggedIn( $user ) {
$cookie = RequestContext::getMain()->getRequest()->getCookie( 'VEE', '' ); $cookie = RequestContext::getMain()->getRequest()->getCookie( 'VEE', '' );
@ -1303,7 +1268,5 @@ class VisualEditorHooks {
} }
) ); ) );
} }
return true;
} }
} }