&& $user->getEmail()
&& !$this->manager->getAuthenticationSessionData( 'no-email' )
) {
- $status = $user->sendConfirmationMail();
- $user->saveSettings();
- if ( $status->isGood() ) {
- // TODO show 'confirmemail_oncreate' success message
- } else {
- // TODO show 'confirmemail_sendfailed' error message
- $this->logger->warning( 'Could not send confirmation email: ' .
- $status->getWikiText( false, false, 'en' ) );
- }
+ // TODO show 'confirmemail_oncreate'/'confirmemail_sendfailed' message
+ wfGetDB( DB_MASTER )->onTransactionIdle( function () use ( $user ) {
+ $user = $user->getInstanceForUpdate();
+ $status = $user->sendConfirmationMail();
+ $user->saveSettings();
+ if ( !$status->isGood() ) {
+ $this->logger->warning( 'Could not send confirmation email: ' .
+ $status->getWikiText( false, false, 'en' ) );
+ }
+ } );
}
return AuthenticationResponse::newPass();
$creator = $this->getMock( 'User' );
$userWithoutEmail = $this->getMock( 'User' );
$userWithoutEmail->expects( $this->any() )->method( 'getEmail' )->willReturn( '' );
+ $userWithoutEmail->expects( $this->any() )->method( 'getInstanceForUpdate' )->willReturnSelf();
$userWithoutEmail->expects( $this->never() )->method( 'sendConfirmationMail' );
$userWithEmailError = $this->getMock( 'User' );
$userWithEmailError->expects( $this->any() )->method( 'getEmail' )->willReturn( 'foo@bar.baz' );
+ $userWithEmailError->expects( $this->any() )->method( 'getInstanceForUpdate' )->willReturnSelf();
$userWithEmailError->expects( $this->any() )->method( 'sendConfirmationMail' )
->willReturn( \Status::newFatal( 'fail' ) );
$userExpectsConfirmation = $this->getMock( 'User' );
$userExpectsConfirmation->expects( $this->any() )->method( 'getEmail' )
->willReturn( 'foo@bar.baz' );
+ $userExpectsConfirmation->expects( $this->any() )->method( 'getInstanceForUpdate' )
+ ->willReturnSelf();
$userExpectsConfirmation->expects( $this->once() )->method( 'sendConfirmationMail' )
->willReturn( \Status::newGood() );
$userNotExpectsConfirmation = $this->getMock( 'User' );
$userNotExpectsConfirmation->expects( $this->any() )->method( 'getEmail' )
->willReturn( 'foo@bar.baz' );
+ $userNotExpectsConfirmation->expects( $this->any() )->method( 'getInstanceForUpdate' )
+ ->willReturnSelf();
$userNotExpectsConfirmation->expects( $this->never() )->method( 'sendConfirmationMail' );
$provider = new EmailNotificationSecondaryAuthenticationProvider( [