$this->loadFromId();
break;
case 'session':
- $this->loadFromSession();
+ if( !$this->loadFromSession() ) {
+ // Loading from session failed. Load defaults.
+ $this->loadDefaults();
+ }
wfRunHooks( 'UserLoadAfterLoadFromSession', array( $this ) );
break;
default:
}
/**
- * Load user data from the session or login cookie. If there are no valid
- * credentials, initialises the user as an anonymous user.
+ * Load user data from the session or login cookie.
* @return Bool True if the user is logged in, false otherwise.
*/
private function loadFromSession() {
if ( $cookieId !== null ) {
$sId = intval( $cookieId );
if( $sessId !== null && $cookieId != $sessId ) {
- $this->loadDefaults(); // Possible collision!
wfDebugLog( 'loginSessions', "Session user ID ($sessId) and
cookie user ID ($sId) don't match!" );
return false;
} elseif ( $sessId !== null && $sessId != 0 ) {
$sId = $sessId;
} else {
- $this->loadDefaults();
return false;
}
$sName = $request->getCookie( 'UserName' );
$request->setSessionData( 'wsUserName', $sName );
} else {
- $this->loadDefaults();
return false;
}
$proposedUser = User::newFromId( $sId );
if ( !$proposedUser->isLoggedIn() ) {
# Not a valid ID
- $this->loadDefaults();
return false;
}
global $wgBlockDisablesLogin;
if( $wgBlockDisablesLogin && $proposedUser->isBlocked() ) {
# User blocked and we've disabled blocked user logins
- $this->loadDefaults();
return false;
}
$from = 'cookie';
} else {
# No session or persistent login cookie
- $this->loadDefaults();
return false;
}
} else {
# Invalid credentials
wfDebug( "User: can't log in from $from, invalid credentials\n" );
- $this->loadDefaults();
return false;
}
}