Remove use of global $wgUser

This partially reverts commit 83a181ce9c
and fully reverts 82896eff62

To avoid regressing to the errors from T139665, check if the user
retrieved from RequestContext::getMain()->getUser() is safe to load
instead of $wgUser, still in addition to the other checks that
EchoForeignWikiRequest::$user is safe to load.

Bug: T243732
Change-Id: I22c4918fc7e8b3d1364a95de3958c055059971b8
This commit is contained in:
DannyS712 2020-01-27 01:52:28 +00:00 committed by DannyS712
parent 9cf347019b
commit 3269afae8e

View file

@ -66,11 +66,10 @@ class EchoForeignWikiRequest {
}
protected function canUseCentralAuth() {
// phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgUser
global $wgFullyInitialised, $wgUser;
global $wgFullyInitialised;
return $wgFullyInitialised &&
$wgUser->isSafeToLoad() &&
RequestContext::getMain()->getUser()->isSafeToLoad() &&
$this->user->isSafeToLoad() &&
SessionManager::getGlobalSession()->getProvider() instanceof CentralAuthSessionProvider &&
$this->getCentralId( $this->user ) !== 0;