fix some spacing
[lhc/web/wiklou.git] / includes / specials / SpecialUserlogin.php
index 705f14f..ddd57c3 100644 (file)
@@ -373,32 +373,34 @@ 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;
                        }
                }
 
                # if you need a confirmed email address to edit, then obviously you
                # need an email address.
-               if ( $wgEmailConfirmToEdit && empty( $this->mEmail ) ) {
+               if ( $wgEmailConfirmToEdit && strval( $this->mEmail ) === '' ) {
                        return Status::newFatal( 'noemailtitle' );
                }
 
-               if( !empty( $this->mEmail ) && !Sanitizer::validateEmail( $this->mEmail ) ) {
+               if ( strval( $this->mEmail ) !== '' && !Sanitizer::validateEmail( $this->mEmail ) ) {
                        return Status::newFatal( 'invalidemailaddress' );
                }
 
@@ -602,7 +604,7 @@ class LoginForm extends SpecialPage {
                                // faces etc will probably just fail cleanly here.
                                $retval = self::RESET_PASS;
                        } else {
-                               $retval = ( $this->mPassword  == '' ) ? self::EMPTY_PASS : self::WRONG_PASS;
+                               $retval = ( $this->mPassword == '' ) ? self::EMPTY_PASS : self::WRONG_PASS;
                        }
                } elseif ( $wgBlockDisablesLogin && $u->isBlocked() ) {
                        // If we've enabled it, make it so that a blocked user cannot login
@@ -745,7 +747,7 @@ class LoginForm extends SpecialPage {
                        case self::SUCCESS:
                                # We've verified now, update the real record
                                $user = $this->getUser();
-                               if( (bool)$this->mRemember != (bool)$user->getOption( 'rememberpassword' ) ) {
+                               if( (bool)$this->mRemember != $user->getBoolOption( 'rememberpassword' ) ) {
                                        $user->setOption( 'rememberpassword', $this->mRemember ? 1 : 0 );
                                        $user->saveSettings();
                                } else {
@@ -868,7 +870,6 @@ class LoginForm extends SpecialPage {
                return $result;
        }
 
-
        /**
         * Run any hooks registered for logins, then HTTP redirect to
         * $this->mReturnTo (or Main Page if that's undefined).  Formerly we had a
@@ -1033,7 +1034,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 {