Merge "Declare visibility on class properties of LoginForm"
[lhc/web/wiklou.git] / includes / specials / SpecialUserlogin.php
index 8304db0..e6ff8bc 100644 (file)
@@ -113,7 +113,7 @@ class LoginForm extends SpecialPage {
                $this->mCookieCheck = $request->getVal( 'wpCookieCheck' );
                $this->mPosted = $request->wasPosted();
                $this->mCreateaccountMail = $request->getCheck( 'wpCreateaccountMail' )
-                                                                       && $wgEnableEmail;
+                       && $wgEnableEmail;
                $this->mCreateaccount = $request->getCheck( 'wpCreateaccount' ) && !$this->mCreateaccountMail;
                $this->mLoginattempt = $request->getCheck( 'wpLoginattempt' );
                $this->mAction = $request->getVal( 'action' );
@@ -146,9 +146,10 @@ class LoginForm extends SpecialPage {
                # 2. Do not return to PasswordReset after a successful password change
                #    but goto Wiki start page (Main_Page) instead ( bug 33997 )
                $returnToTitle = Title::newFromText( $this->mReturnTo );
-               if ( is_object( $returnToTitle ) && (
-                       $returnToTitle->isSpecial( 'Userlogout' )
-                       || $returnToTitle->isSpecial( 'PasswordReset' ) ) ) {
+               if ( is_object( $returnToTitle )
+                       && ( $returnToTitle->isSpecial( 'Userlogout' )
+                               || $returnToTitle->isSpecial( 'PasswordReset' ) )
+               ) {
                        $this->mReturnTo = '';
                        $this->mReturnToQuery = '';
                }
@@ -195,6 +196,7 @@ class LoginForm extends SpecialPage {
                                $this->getOutput()->redirect( $url );
                                // Since we only do this redir to change proto, always vary
                                $this->getOutput()->addVaryHeader( 'X-Forwarded-Proto' );
+
                                return;
                        } else {
                                // A wiki without HTTPS login support should set $wgServer to
@@ -208,16 +210,20 @@ class LoginForm extends SpecialPage {
 
                if ( !is_null( $this->mCookieCheck ) ) {
                        $this->onCookieRedirectCheck( $this->mCookieCheck );
+
                        return;
                } elseif ( $this->mPosted ) {
                        if ( $this->mCreateaccount ) {
                                $this->addNewAccount();
+
                                return;
                        } elseif ( $this->mCreateaccountMail ) {
                                $this->addNewAccountMailPassword();
+
                                return;
                        } elseif ( ( 'submitlogin' == $this->mAction ) || $this->mLoginattempt ) {
                                $this->processLogin();
+
                                return;
                        }
                }
@@ -230,6 +236,7 @@ class LoginForm extends SpecialPage {
        function addNewAccountMailPassword() {
                if ( $this->mEmail == '' ) {
                        $this->mainLoginForm( $this->msg( 'noemailcreate' )->escaped() );
+
                        return;
                }
 
@@ -237,6 +244,7 @@ class LoginForm extends SpecialPage {
                if ( !$status->isGood() ) {
                        $error = $status->getMessage();
                        $this->mainLoginForm( $error->toString() );
+
                        return;
                }
 
@@ -273,6 +281,7 @@ class LoginForm extends SpecialPage {
                if ( !$status->isGood() ) {
                        $error = $status->getMessage();
                        $this->mainLoginForm( $error->toString() );
+
                        return false;
                }
 
@@ -336,6 +345,7 @@ class LoginForm extends SpecialPage {
                        wfRunHooks( 'AddNewAccount', array( $u, false ) );
                        $u->addNewUserLogEntry( 'create2', $this->mReason );
                }
+
                return true;
        }
 
@@ -378,6 +388,7 @@ class LoginForm extends SpecialPage {
                # Request forgery checks.
                if ( !self::getCreateaccountToken() ) {
                        self::setCreateaccountToken();
+
                        return Status::newFatal( 'nocookiesfornew' );
                }
 
@@ -399,6 +410,7 @@ class LoginForm extends SpecialPage {
                } elseif ( $creationBlock instanceof Block ) {
                        // Throws an ErrorPageError.
                        $this->userBlockedMessage( $creationBlock );
+
                        // This should never be reached.
                        return false;
                }
@@ -406,7 +418,7 @@ class LoginForm extends SpecialPage {
                # Include checks that will include GlobalBlocking (Bug 38333)
                $permErrors = $this->getPageTitle()->getUserPermissionsErrors( 'createaccount', $currentUser, true );
                if ( count( $permErrors ) ) {
-                               throw new PermissionsError( 'createaccount', $permErrors );
+                       throw new PermissionsError( 'createaccount', $permErrors );
                }
 
                $ip = $this->getRequest()->getIP();
@@ -444,6 +456,7 @@ class LoginForm extends SpecialPage {
                                if ( !is_array( $valid ) ) {
                                        $valid = array( $valid, $wgMinimalPasswordLength );
                                }
+
                                return call_user_func_array( 'Status::newFatal', $valid );
                        }
                }
@@ -475,6 +488,7 @@ class LoginForm extends SpecialPage {
                                // To return a different error code, return a Status object.
                                $abortError = new Message( 'createaccount-hook-aborted', array( $abortError ) );
                                $abortError->text();
+
                                return Status::newFatal( $abortError );
                        } else {
                                // For MediaWiki 1.23+ and updated hooks, return the Status object
@@ -505,6 +519,7 @@ class LoginForm extends SpecialPage {
                }
 
                self::clearCreateaccountToken();
+
                return $this->initUser( $u, false );
        }
 
@@ -572,6 +587,7 @@ class LoginForm extends SpecialPage {
                // If the user doesn't have a login token yet, set one.
                if ( !self::getLoginToken() ) {
                        self::setLoginToken();
+
                        return self::NEED_TOKEN;
                }
                // If the user didn't pass a login token, tell them we need one
@@ -597,6 +613,7 @@ class LoginForm extends SpecialPage {
                // will effectively be using stale data.
                if ( $this->getUser()->getName() === $this->mUsername ) {
                        wfDebug( __METHOD__ . ": already logged in as {$this->mUsername}\n" );
+
                        return self::SUCCESS;
                }
 
@@ -622,6 +639,7 @@ class LoginForm extends SpecialPage {
                $msg = null;
                if ( !wfRunHooks( 'AbortLogin', array( $u, $this->mPassword, &$abort, &$msg ) ) ) {
                        $this->mAbortLoginErrorMsg = $msg;
+
                        return $abort;
                }
 
@@ -686,6 +704,7 @@ class LoginForm extends SpecialPage {
                        $retval = self::SUCCESS;
                }
                wfRunHooks( 'LoginAuthenticateAudit', array( $u, $this->mPassword, $retval ) );
+
                return $retval;
        }
 
@@ -744,17 +763,23 @@ class LoginForm extends SpecialPage {
 
                if ( $this->getUser()->isBlockedFromCreateAccount() ) {
                        wfDebug( __METHOD__ . ": user is blocked from account creation\n" );
+
                        return self::CREATE_BLOCKED;
                }
+
                if ( !$wgAuth->autoCreate() ) {
                        return self::NOT_EXISTS;
                }
+
                if ( !$wgAuth->userExists( $user->getName() ) ) {
                        wfDebug( __METHOD__ . ": user does not exist\n" );
+
                        return self::NOT_EXISTS;
                }
+
                if ( !$wgAuth->authenticate( $user->getName(), $this->mPassword ) ) {
                        wfDebug( __METHOD__ . ": \$wgAuth->authenticate() returned false, aborting\n" );
+
                        return self::WRONG_PLUGIN_PASS;
                }
 
@@ -763,6 +788,7 @@ class LoginForm extends SpecialPage {
                        // Hook point to add extra creation throttles and blocks
                        wfDebug( "LoginForm::attemptAutoCreate: a hook blocked creation: $abortError\n" );
                        $this->mAbortLoginErrorMsg = $abortError;
+
                        return self::ABORTED;
                }
 
@@ -772,6 +798,7 @@ class LoginForm extends SpecialPage {
                if ( !$status->isOK() ) {
                        $errors = $status->getErrorsByType( 'error' );
                        $this->mAbortLoginErrorMsg = $errors[0]['message'];
+
                        return self::ABORTED;
                }
 
@@ -780,7 +807,7 @@ class LoginForm extends SpecialPage {
 
        function processLogin() {
                global $wgMemc, $wgLang, $wgSecureLogin, $wgPasswordAttemptThrottle,
-                       $wgInvalidPasswordReset;
+                          $wgInvalidPasswordReset;
 
                switch ( $this->authenticateUserData() ) {
                        case self::SUCCESS:
@@ -882,8 +909,8 @@ class LoginForm extends SpecialPage {
                        case self::THROTTLED:
                                $error = $this->mAbortLoginErrorMsg ?: 'login-throttled';
                                $this->mainLoginForm( $this->msg( $error )
-                               ->params ( $this->getLanguage()->formatDuration( $wgPasswordAttemptThrottle['seconds'] ) )
-                               ->text()
+                                       ->params( $this->getLanguage()->formatDuration( $wgPasswordAttemptThrottle['seconds'] ) )
+                                       ->text()
                                );
                                break;
                        case self::USER_BLOCKED:
@@ -1145,6 +1172,7 @@ class LoginForm extends SpecialPage {
                                throw new PermissionsError( 'createaccount', $permErrors );
                        } elseif ( $user->isBlockedFromCreateAccount() ) {
                                $this->userBlockedMessage( $user->isBlockedFromCreateAccount() );
+
                                return;
                        } elseif ( wfReadOnly() ) {
                                throw new ReadOnlyError;
@@ -1336,6 +1364,7 @@ class LoginForm extends SpecialPage {
         */
        function hasSessionCookie() {
                global $wgDisableCookieCheck;
+
                return $wgDisableCookieCheck ? true : $this->getRequest()->checkSessionCookie();
        }
 
@@ -1345,6 +1374,7 @@ class LoginForm extends SpecialPage {
         */
        public static function getLoginToken() {
                global $wgRequest;
+
                return $wgRequest->getSessionData( 'wsLoginToken' );
        }
 
@@ -1372,6 +1402,7 @@ class LoginForm extends SpecialPage {
         */
        public static function getCreateaccountToken() {
                global $wgRequest;
+
                return $wgRequest->getSessionData( 'wsCreateaccountToken' );
        }
 
@@ -1454,6 +1485,7 @@ class LoginForm extends SpecialPage {
                                        $links[] = $this->makeLanguageSelectorLink( $parts[0], trim( $parts[1] ) );
                                }
                        }
+
                        return count( $links ) > 0 ? $this->msg( 'loginlanguagelabel' )->rawParams(
                                $this->getLanguage()->pipeList( $links ) )->escaped() : '';
                } else {