Some bugzilla.wikimedia.org -> phabricator.wikimedia.org changes
[lhc/web/wiklou.git] / includes / specials / SpecialUserlogin.php
index 0b500f4..ee78a61 100644 (file)
@@ -559,7 +559,13 @@ class LoginForm extends SpecialPage {
                $u = User::newFromName( $this->mUsername, 'creatable' );
                if ( !$u ) {
                        return Status::newFatal( 'noname' );
-               } elseif ( 0 != $u->idForName( User::READ_LOCKING ) ) {
+               }
+
+               # Make sure the user does not exist already
+               $lock = $wgMemc->getScopedLock( wfGlobalCacheKey( 'account', md5( $this->mUsername ) ) );
+               if ( !$lock ) {
+                       return Status::newFatal( 'usernameinprogress' );
+               } elseif ( $u->idForName( User::READ_LOCKING ) ) {
                        return Status::newFatal( 'userexists' );
                }
 
@@ -668,7 +674,12 @@ class LoginForm extends SpecialPage {
                $u->setRealName( $this->mRealName );
                $u->setToken();
 
+               Hooks::run( 'LocalUserCreated', array( $u, $autocreate ) );
+               $oldUser = $u;
                $wgAuth->initUser( $u, $autocreate );
+               if ( $oldUser !== $u ) {
+                       wfWarn( get_class( $wgAuth ) . '::initUser() replaced the user object' );
+               }
 
                $u->saveSettings();
 
@@ -814,7 +825,12 @@ class LoginForm extends SpecialPage {
                        $retval = self::RESET_PASS;
                        $this->mAbortLoginErrorMsg = 'resetpass-expired';
                } else {
+                       Hooks::run( 'UserLoggedIn', array( $u ) );
+                       $oldUser = $u;
                        $wgAuth->updateUser( $u );
+                       if ( $oldUser !== $u ) {
+                               wfWarn( get_class( $wgAuth ) . '::updateUser() replaced the user object' );
+                       }
                        $wgUser = $u;
                        // This should set it for OutputPage and the Skin
                        // which is needed or the personal links will be
@@ -939,8 +955,8 @@ class LoginForm extends SpecialPage {
                global $wgMemc, $wgLang, $wgSecureLogin, $wgPasswordAttemptThrottle,
                        $wgInvalidPasswordReset;
 
-               $status = $this->authenticateUserData();
-               switch ( $status ) {
+               $authRes = $this->authenticateUserData();
+               switch ( $authRes ) {
                        case self::SUCCESS:
                                # We've verified now, update the real record
                                $user = $this->getUser();
@@ -1066,8 +1082,8 @@ class LoginForm extends SpecialPage {
 
                LoggerFactory::getInstance( 'authmanager' )->info( 'Login attempt', array(
                        'event' => 'login',
-                       'successful' => $status === self::SUCCESS,
-                       'status' => LoginForm::$statusCodes[$status],
+                       'successful' => $authRes === self::SUCCESS,
+                       'status' => LoginForm::$statusCodes[$authRes],
                ) );
        }
 
@@ -1361,13 +1377,10 @@ class LoginForm extends SpecialPage {
                        'mediawiki.ui.input',
                        'mediawiki.special.userlogin.common.styles'
                ) );
-               $out->addModules( array(
-                       'mediawiki.special.userlogin.common.js'
-               ) );
 
                if ( $this->mType == 'signup' ) {
                        // XXX hack pending RL or JS parse() support for complex content messages
-                       // https://bugzilla.wikimedia.org/show_bug.cgi?id=25349
+                       // https://phabricator.wikimedia.org/T27349
                        $out->addJsConfigVars( 'wgCreateacctImgcaptchaHelp',
                                $this->msg( 'createacct-imgcaptcha-help' )->parse() );