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
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()
];