auth: Make 'LocalUserCreated' hook non-abortable
[lhc/web/wiklou.git] / includes / auth / AuthManager.php
index 9686555..bfe278b 100644 (file)
@@ -232,7 +232,9 @@ class AuthManager implements LoggerAwareInterface {
        }
 
        /**
-        * Call a legacy AuthPlugin method, if necessary
+        * This used to call a legacy AuthPlugin method, if necessary. Since that code has
+        * been removed, it now just returns the $return parameter.
+        *
         * @codeCoverageIgnore
         * @deprecated For backwards compatibility only, should be avoided in new code
         * @param string $method AuthPlugin method to call
@@ -241,13 +243,8 @@ class AuthManager implements LoggerAwareInterface {
         * @return mixed Return value from the AuthPlugin method, or $return
         */
        public static function callLegacyAuthPlugin( $method, array $params, $return = null ) {
-               global $wgAuth;
-
-               if ( $wgAuth && !$wgAuth instanceof AuthManagerAuthPlugin ) {
-                       return $wgAuth->$method( ...$params );
-               } else {
-                       return $return;
-               }
+               wfDeprecated( __METHOD__, '1.33' );
+               return $return;
        }
 
        /**
@@ -1009,7 +1006,7 @@ class AuthManager implements LoggerAwareInterface {
                if ( $block ) {
                        $errorParams = [
                                $block->getTarget(),
-                               $block->mReason ?: wfMessage( 'blockednoreason' )->text(),
+                               $block->getReason() ?: wfMessage( 'blockednoreason' )->text(),
                                $block->getByName()
                        ];
 
@@ -1426,7 +1423,7 @@ class AuthManager implements LoggerAwareInterface {
                                        // @codeCoverageIgnoreEnd
                                }
                                $this->setDefaultUserOptions( $user, $creator->isAnon() );
-                               \Hooks::run( 'LocalUserCreated', [ $user, false ] );
+                               \Hooks::runWithoutAbort( 'LocalUserCreated', [ $user, false ] );
                                $user->saveSettings();
                                $state['userid'] = $user->getId();
 
@@ -1635,7 +1632,9 @@ class AuthManager implements LoggerAwareInterface {
 
                // Is the IP user able to create accounts?
                $anon = new User;
-               if ( !$anon->isAllowedAny( 'createaccount', 'autocreateaccount' ) ) {
+               if ( $source !== self::AUTOCREATE_SOURCE_MAINT &&
+                       !$anon->isAllowedAny( 'createaccount', 'autocreateaccount' )
+               ) {
                        $this->logger->debug( __METHOD__ . ': IP lacks the ability to create or autocreate accounts', [
                                'username' => $username,
                                'ip' => $anon->getName(),
@@ -1743,7 +1742,6 @@ class AuthManager implements LoggerAwareInterface {
                // Inform the providers
                $this->callMethodOnProviders( 6, 'autoCreatedAccount', [ $user, $source ] );
 
-               \Hooks::run( 'AuthPluginAutoCreate', [ $user ], '1.27' );
                \Hooks::run( 'LocalUserCreated', [ $user, true ] );
                $user->saveSettings();