Hard-deprecate authentication-related hooks deprecated by AuthManager

Hard-deprecates AbortAutoAccount, AbortNewAccount, AbortLogin,
LoginUserMigrated, UserCreateForm, and UserLoginForm.

Change-Id: Ibb267def9c295997ef71d820ff482e1e6a816873
This commit is contained in:
Gergő Tisza 2018-09-19 15:19:59 -07:00
parent 25fa7f8338
commit efa7a92e7c
No known key found for this signature in database
GPG key ID: C34FEC97E6257F96
3 changed files with 8 additions and 6 deletions

View file

@ -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(

View file

@ -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' );
}

View file

@ -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" );
}