From: Gergő Tisza Date: Wed, 19 Sep 2018 22:19:59 +0000 (-0700) Subject: Hard-deprecate authentication-related hooks deprecated by AuthManager X-Git-Tag: 1.34.0-rc.0~3842^2 X-Git-Url: https://git.cyclocoop.org/admin/?a=commitdiff_plain;h=efa7a92e7c115bd59a56ed9a30e1a81ca8a03016;p=lhc%2Fweb%2Fwiklou.git Hard-deprecate authentication-related hooks deprecated by AuthManager Hard-deprecates AbortAutoAccount, AbortNewAccount, AbortLogin, LoginUserMigrated, UserCreateForm, and UserLoginForm. Change-Id: Ibb267def9c295997ef71d820ff482e1e6a816873 --- diff --git a/includes/auth/LegacyHookPreAuthenticationProvider.php b/includes/auth/LegacyHookPreAuthenticationProvider.php index e8a276cc2d..ad8856491f 100644 --- a/includes/auth/LegacyHookPreAuthenticationProvider.php +++ b/includes/auth/LegacyHookPreAuthenticationProvider.php @@ -56,7 +56,7 @@ class LegacyHookPreAuthenticationProvider extends AbstractPreAuthenticationProvi } $msg = null; - if ( !\Hooks::run( 'LoginUserMigrated', [ $user, &$msg ] ) ) { + if ( !\Hooks::run( 'LoginUserMigrated', [ $user, &$msg ], '1.27' ) ) { return $this->makeFailResponse( $user, LoginForm::USER_MIGRATED, $msg, 'LoginUserMigrated' ); @@ -64,7 +64,7 @@ class LegacyHookPreAuthenticationProvider extends AbstractPreAuthenticationProvi $abort = LoginForm::ABORTED; $msg = null; - if ( !\Hooks::run( 'AbortLogin', [ $user, $password, &$abort, &$msg ] ) ) { + if ( !\Hooks::run( 'AbortLogin', [ $user, $password, &$abort, &$msg ], '1.27' ) ) { return $this->makeFailResponse( $user, $abort, $msg, 'AbortLogin' ); } @@ -74,7 +74,7 @@ class LegacyHookPreAuthenticationProvider extends AbstractPreAuthenticationProvi public function testForAccountCreation( $user, $creator, array $reqs ) { $abortError = ''; $abortStatus = null; - if ( !\Hooks::run( 'AbortNewAccount', [ $user, &$abortError, &$abortStatus ] ) ) { + if ( !\Hooks::run( 'AbortNewAccount', [ $user, &$abortError, &$abortStatus ], '1.27' ) ) { // Hook point to add extra creation throttles and blocks $this->logger->debug( __METHOD__ . ': a hook blocked creation' ); if ( $abortStatus === null ) { @@ -99,7 +99,7 @@ class LegacyHookPreAuthenticationProvider extends AbstractPreAuthenticationProvi public function testUserForCreation( $user, $autocreate, array $options = [] ) { if ( $autocreate !== false ) { $abortError = ''; - if ( !\Hooks::run( 'AbortAutoAccount', [ $user, &$abortError ] ) ) { + if ( !\Hooks::run( 'AbortAutoAccount', [ $user, &$abortError ], '1.27' ) ) { // Hook point to add extra creation throttles and blocks $this->logger->debug( __METHOD__ . ": a hook blocked auto-creation: $abortError\n" ); return $this->makeFailResponse( diff --git a/includes/specialpage/LoginSignupSpecialPage.php b/includes/specialpage/LoginSignupSpecialPage.php index e39ec5823d..99a5a9a844 100644 --- a/includes/specialpage/LoginSignupSpecialPage.php +++ b/includes/specialpage/LoginSignupSpecialPage.php @@ -824,12 +824,12 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage { // Both Hooks::run are explicit here to make findHooks.php happy if ( $this->isSignup() ) { - Hooks::run( 'UserCreateForm', [ &$template ] ); + Hooks::run( 'UserCreateForm', [ &$template ], '1.27' ); if ( $oldTemplate !== $template ) { wfDeprecated( "reference in UserCreateForm hook", '1.27' ); } } else { - Hooks::run( 'UserLoginForm', [ &$template ] ); + Hooks::run( 'UserLoginForm', [ &$template ], '1.27' ); if ( $oldTemplate !== $template ) { wfDeprecated( "reference in UserLoginForm hook", '1.27' ); } diff --git a/tests/phpunit/includes/auth/LegacyHookPreAuthenticationProviderTest.php b/tests/phpunit/includes/auth/LegacyHookPreAuthenticationProviderTest.php index 38ccb8a3cb..4b89d254e2 100644 --- a/tests/phpunit/includes/auth/LegacyHookPreAuthenticationProviderTest.php +++ b/tests/phpunit/includes/auth/LegacyHookPreAuthenticationProviderTest.php @@ -44,6 +44,8 @@ class LegacyHookPreAuthenticationProviderTest extends \MediaWikiTestCase { $this->mergeMwGlobalArrayValue( 'wgHooks', [ $hook => [ $mock ], ] ); + $mockClass = get_class( $mock ); + $this->hideDeprecated( "$hook hook (used in $mockClass::on$hook)" ); return $mock->expects( $expect )->method( "on$hook" ); }