Merge "Fix edit link for messages in $wgForceUIMsgAsContentMsg"
[lhc/web/wiklou.git] / includes / specials / SpecialUserlogin.php
index f2f6b69..64a6f72 100644 (file)
@@ -194,13 +194,13 @@ class LoginForm extends SpecialPage {
                        && in_array( $entryError->getKey(), self::getValidErrorMessages() )
                ) {
                        $this->mEntryErrorType = 'error';
-                       $this->mEntryError = $entryError->rawParams( $loginreqlink )->escaped();
+                       $this->mEntryError = $entryError->rawParams( $loginreqlink )->parse();
 
                } elseif ( $entryWarning->exists()
                        && in_array( $entryWarning->getKey(), self::getValidErrorMessages() )
                ) {
                        $this->mEntryErrorType = 'warning';
-                       $this->mEntryError = $entryWarning->rawParams( $loginreqlink )->escaped();
+                       $this->mEntryError = $entryWarning->rawParams( $loginreqlink )->parse();
                }
 
                if ( $wgEnableEmail ) {
@@ -545,14 +545,11 @@ class LoginForm extends SpecialPage {
                                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 );
+                       # check for password validity, return a fatal Status if invalid
+                       $validity = $u->checkPasswordValidity( $this->mPassword );
+                       if ( !$validity->isGood() ) {
+                               $validity->ok = false; // make sure this Status is fatal
+                               return $validity;
                        }
                }
 
@@ -713,7 +710,11 @@ class LoginForm extends SpecialPage {
                }
 
                $u = User::newFromName( $this->mUsername );
+               if ( $u === false ) {
+                       return self::ILLEGAL;
+               }
 
+               $msg = null;
                // Give extensions a way to indicate the username has been updated,
                // rather than telling the user the account doesn't exist.
                if ( !Hooks::run( 'LoginUserMigrated', array( $u, &$msg ) ) ) {
@@ -721,7 +722,7 @@ class LoginForm extends SpecialPage {
                        return self::USER_MIGRATED;
                }
 
-               if ( !( $u instanceof User ) || !User::isUsableName( $u->getName() ) ) {
+               if ( !User::isUsableName( $u->getName() ) ) {
                        return self::ILLEGAL;
                }
 
@@ -739,7 +740,6 @@ class LoginForm extends SpecialPage {
 
                // Give general extensions, such as a captcha, a chance to abort logins
                $abort = self::ABORTED;
-               $msg = null;
                if ( !Hooks::run( 'AbortLogin', array( $u, $this->mPassword, &$abort, &$msg ) ) ) {
                        $this->mAbortLoginErrorMsg = $msg;
 
@@ -765,7 +765,7 @@ class LoginForm extends SpecialPage {
                                // As a side-effect, we can authenticate the user's e-mail ad-
                                // dress if it's not already done, since the temporary password
                                // was sent via e-mail.
-                               if ( !$u->isEmailConfirmed() ) {
+                               if ( !$u->isEmailConfirmed() && !wfReadOnly() ) {
                                        $u->confirmEmail();
                                        $u->saveSettings();
                                }
@@ -916,7 +916,7 @@ class LoginForm extends SpecialPage {
                        case self::SUCCESS:
                                # We've verified now, update the real record
                                $user = $this->getUser();
-                               $user->invalidateCache();
+                               $user->touch();
 
                                if ( $user->requiresHTTPS() ) {
                                        $this->mStickHTTPS = true;