API: Improve list=random
[lhc/web/wiklou.git] / includes / specials / SpecialUserlogin.php
index 0b500f4..0410ef0 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' );
                }
 
@@ -939,8 +945,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 +1072,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,9 +1367,6 @@ 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