Merge "Hard-deprecate authentication-related hooks deprecated by AuthManager"
[lhc/web/wiklou.git] / includes / auth / LegacyHookPreAuthenticationProvider.php
index 97bbde7..ad88564 100644 (file)
@@ -56,16 +56,16 @@ class LegacyHookPreAuthenticationProvider extends AbstractPreAuthenticationProvi
                }
 
                $msg = null;
-               if ( !\Hooks::run( 'LoginUserMigrated', [ $user, &$msg ] ) ) {
+               if ( !\Hooks::run( 'LoginUserMigrated', [ $user, &$msg ], '1.27' ) ) {
                        return $this->makeFailResponse(
-                               $user, null, LoginForm::USER_MIGRATED, $msg, 'LoginUserMigrated'
+                               $user, LoginForm::USER_MIGRATED, $msg, 'LoginUserMigrated'
                        );
                }
 
                $abort = LoginForm::ABORTED;
                $msg = null;
-               if ( !\Hooks::run( 'AbortLogin', [ $user, $password, &$abort, &$msg ] ) ) {
-                       return $this->makeFailResponse( $user, null, $abort, $msg, 'AbortLogin' );
+               if ( !\Hooks::run( 'AbortLogin', [ $user, $password, &$abort, &$msg ], '1.27' ) ) {
+                       return $this->makeFailResponse( $user, $abort, $msg, 'AbortLogin' );
                }
 
                return StatusValue::newGood();
@@ -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,11 +99,11 @@ 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(
-                                       $user, $user, LoginForm::ABORTED, $abortError, 'AbortAutoAccount'
+                                       $user, LoginForm::ABORTED, $abortError, 'AbortAutoAccount'
                                );
                        }
                }
@@ -114,13 +114,12 @@ class LegacyHookPreAuthenticationProvider extends AbstractPreAuthenticationProvi
        /**
         * Construct an appropriate failure response
         * @param User $user
-        * @param User|null $creator
         * @param int $constant One of the LoginForm::… constants
         * @param string|null $msg Optional message key, will be derived from $constant otherwise
         * @param string $hook Name of the hook for error logging and exception messages
         * @return StatusValue
         */
-       protected function makeFailResponse( $user, $creator, $constant, $msg, $hook ) {
+       private function makeFailResponse( User $user, $constant, $msg, $hook ) {
                switch ( $constant ) {
                        case LoginForm::SUCCESS:
                                // WTF?
@@ -169,7 +168,7 @@ class LegacyHookPreAuthenticationProvider extends AbstractPreAuthenticationProvi
 
                        case LoginForm::USER_MIGRATED:
                                $error = $msg ?: 'login-migrated-generic';
-                               return call_user_func_array( 'StatusValue::newFatal', (array)$error );
+                               return StatusValue::newFatal( ...(array)$error );
 
                        // @codeCoverageIgnoreStart
                        case LoginForm::CREATE_BLOCKED: // Can never happen