From ce38c198a4eb216b1ad5314b27edaf4789508d28 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Thu, 5 Oct 2017 14:50:44 -0400 Subject: [PATCH] CheckBlocksSecondaryAuthenticationProvider: Avoid user language during auto-creation If a user being auto-created is blocked from account creation without a reason given, CheckBlocksPrimaryAuthProvider is triggering a "User::loadFromSession called before the end of Setup.php" log message when trying to fill in a reason using 'blockednoreason'. In this situation, use the content language instead. Bug: T124367 Change-Id: Id94c919cdba5e4218b709ba8ac9d0fa17f0c3f8e --- .../CheckBlocksSecondaryAuthenticationProvider.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/includes/auth/CheckBlocksSecondaryAuthenticationProvider.php b/includes/auth/CheckBlocksSecondaryAuthenticationProvider.php index f7a7ec193d..7488fbaaae 100644 --- a/includes/auth/CheckBlocksSecondaryAuthenticationProvider.php +++ b/includes/auth/CheckBlocksSecondaryAuthenticationProvider.php @@ -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() ]; -- 2.20.1