Remove optimization that avoids unstubbing $wgUser because $wgUser
is not a plain object for the current user name.
It's a stub with mFrom='session' until methods are called that need
the info, such as getName(), which then lazy loads the object based on
the session information.
We want to make load.php session-less.
Bug: T127233
Change-Id: Ica482e5d1892cb29456e6f2a91cd70017cf414c5
if ( $this->userObj === null ) {
$username = $this->getUser();
if ( $username ) {
- // Optimize: Avoid loading a new User object if possible
- global $wgUser;
- if ( is_object( $wgUser ) && $wgUser->getName() === $username ) {
- $this->userObj = $wgUser;
- } else {
- $this->userObj = User::newFromName( $username );
- }
+ $this->userObj = User::newFromName( $username );
} else {
$this->userObj = new User; // Anonymous user
}