Merge "CheckBlocksSecondaryAuthenticationProvider: Avoid user language during auto...
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 26 Oct 2017 22:44:23 +0000 (22:44 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 26 Oct 2017 22:44:23 +0000 (22:44 +0000)
includes/auth/CheckBlocksSecondaryAuthenticationProvider.php

index f7a7ec1..7488fba 100644 (file)
@@ -77,9 +77,19 @@ class CheckBlocksSecondaryAuthenticationProvider extends AbstractSecondaryAuthen
        public function testUserForCreation( $user, $autocreate, array $options = [] ) {
                $block = $user->isBlockedFromCreateAccount();
                if ( $block ) {
+                       if ( $block->mReason ) {
+                               $reason = $block->mReason;
+                       } else {
+                               $msg = \Message::newFromKey( 'blockednoreason' );
+                               if ( !\RequestContext::getMain()->getUser()->isSafeToLoad() ) {
+                                       $msg->inContentLanguage();
+                               }
+                               $reason = $msg->text();
+                       }
+
                        $errorParams = [
                                $block->getTarget(),
-                               $block->mReason ?: \Message::newFromKey( 'blockednoreason' )->text(),
+                               $reason,
                                $block->getByName()
                        ];