Page MenuHomePhabricator

ForeignWikiRequest uses $wgUser (causes test failure)
Closed, ResolvedPublic


Seen on an unrelated patch...

03:04:20 FILE: /workspace/src/extensions/Echo/includes/ForeignWikiRequest.php
03:04:20 ----------------------------------------------------------------------
03:04:20 ----------------------------------------------------------------------
03:04:20  69 | WARNING | Deprecated global $wgUser used
03:04:20     |         | (MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgUser)
03:04:20 ----------------------------------------------------------------------

The code uses $wgUser and $this->user... Does it really need to?

	protected function canUseCentralAuth() {
		global $wgFullyInitialised, $wgUser;

		return $wgFullyInitialised &&
			$wgUser->isSafeToLoad() &&
			$this->user->isSafeToLoad() &&
			SessionManager::getGlobalSession()->getProvider() instanceof CentralAuthSessionProvider &&
			$this->getCentralId( $this->user ) !== 0;

Ping T139665: "User::loadFromSession called before the end of Setup.php" warning due to Echo and 83a181ce9c840cdf90cb07fce68861e64260a5e5

Roan wrote

Check it for both $wgUser and $this->user because they could theoretically be different.

I mean, he's not wrong... Is this likely today though?

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Reedy triaged this task as High priority.Sep 5 2020, 2:34 AM

High as it's blocking unrelated changes...

Obviously we can just suppress MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgUser, but that doesn't help with T159299: Deprecate and remove $wgUser...

So the question is whethe we can remove it... Is the User object passed into the ForeignWikiRequest constructor likely to be the same as $wgUser etc?

Change 625033 had a related patch set uploaded (by Reedy; owner: Reedy):
[mediawiki/extensions/Echo@master] Remove $wgUser from EchoForeignWikiRequest::canUseCentralAuth()

Change 625033 abandoned by Reedy:
[mediawiki/extensions/Echo@master] Remove $wgUser from EchoForeignWikiRequest::canUseCentralAuth()

Dupe of /567374/

Reedy renamed this task from ForeignWikiRequest uses $wgUser to ForeignWikiRequest uses $wgUser (causes test failure).Sep 5 2020, 2:45 AM
Reedy removed a project: Patch-For-Review.

Change 625039 had a related patch set uploaded (by Reedy; owner: Reedy):
[mediawiki/extensions/Echo@master] Ignore usage of $wgUSer

Change 625039 merged by jenkins-bot:
[mediawiki/extensions/Echo@master] Ignore usage of $wgUser

Reedy claimed this task.
Reedy removed a project: Patch-For-Review.

Mitigated using phpcs:ignore, which unblocks other patches to the repo. T243732: Echo needs uses of global $wgUser removed is for removing the usage