Merge "Tests: Add missing expect numbers in QUnit tests."
[lhc/web/wiklou.git] / includes / specials / SpecialUserlogin.php
index 48dfb19..27701d4 100644 (file)
@@ -43,12 +43,12 @@ class LoginForm extends SpecialPage {
        const NEED_TOKEN = 12;
        const WRONG_TOKEN = 13;
 
-       public $mUsername, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted;
-       public $mAction, $mCreateaccount, $mCreateaccountMail;
-       public $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage;
-       public $mSkipCookieCheck, $mReturnToQuery, $mToken, $mStickHTTPS;
-       public $mType, $mReason, $mRealName;
-       public $mAbortLoginErrorMsg = 'login-abort-generic';
+       var $mUsername, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted;
+       var $mAction, $mCreateaccount, $mCreateaccountMail;
+       var $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage;
+       var $mSkipCookieCheck, $mReturnToQuery, $mToken, $mStickHTTPS;
+       var $mType, $mReason, $mRealName;
+       var $mAbortLoginErrorMsg = 'login-abort-generic';
        private $mLoaded = false;
 
        /**
@@ -373,22 +373,24 @@ class LoginForm extends SpecialPage {
                        return Status::newFatal( 'noname' );
                } elseif ( 0 != $u->idForName() ) {
                        return Status::newFatal( 'userexists' );
-               } elseif ( 0 != strcmp( $this->mPassword, $this->mRetype ) ) {
-                       return Status::newFatal( 'badretype' );
                }
 
-               # check for minimal password length
-               $valid = $u->getPasswordValidity( $this->mPassword );
-               if ( $valid !== true ) {
-                       if ( !$this->mCreateaccountMail ) {
+               if ( $this->mCreateaccountMail ) {
+                       # do not force a password for account creation by email
+                       # set invalid password, it will be replaced later by a random generated password
+                       $this->mPassword = null;
+               } else {
+                       if ( $this->mPassword !== $this->mRetype ) {
+                               return Status::newFatal( 'badretype' );
+                       }
+
+                       # check for minimal password length
+                       $valid = $u->getPasswordValidity( $this->mPassword );
+                       if ( $valid !== true ) {
                                if ( !is_array( $valid ) ) {
                                        $valid = array( $valid, $wgMinimalPasswordLength );
                                }
                                return call_user_func_array( 'Status::newFatal', $valid );
-                       } else {
-                               # do not force a password for account creation by email
-                               # set invalid password, it will be replaced later by a random generated password
-                               $this->mPassword = null;
                        }
                }
 
@@ -1033,7 +1035,8 @@ class LoginForm extends SpecialPage {
                        }
                }
 
-               if ( $this->mUsername == '' ) {
+               // Pre-fill username (if not creating an account, bug 44775).
+               if ( $this->mUsername == '' && $this->mType != 'signup' ) {
                        if ( $user->isLoggedIn() ) {
                                $this->mUsername = $user->getName();
                        } else {