Page MenuHomePhabricator

Stop using $wgUser in Wikibase
Closed, ResolvedPublic

Details

Related Gerrit Patches:
mediawiki/extensions/Wikibase : masterReplace $wgUser with user from RequestContext
mediawiki/extensions/Wikibase : mastertests: Stop using $wgUser

Event Timeline

Daimona created this task.Jan 5 2020, 7:13 PM
Restricted Application added a project: Wikidata. · View Herald TranscriptJan 5 2020, 7:13 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 562066 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/Wikibase@master] tests: Stop using $wgUser

https://gerrit.wikimedia.org/r/562066

Note: there are two usages in the entry point which I'm unsure how to fix.

Azasya closed this task as Declined.Jan 5 2020, 8:22 PM
JJMC89 reopened this task as Open.Jan 5 2020, 8:28 PM
Maintenance_bot moved this task from incoming to in progress on the Wikidata board.Jan 6 2020, 9:15 AM

Change 562066 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] tests: Stop using $wgUser

https://gerrit.wikimedia.org/r/562066

WMDE-leszek removed Daimona as the assignee of this task.Jan 9 2020, 2:59 PM
WMDE-leszek moved this task from Incoming to Ready to estimate on the Wikidata-Campsite board.
Addshore triaged this task as Low priority.Jan 14 2020, 5:11 PM
Addshore added a subscriber: Addshore.

Note: there are two usages in the entry point which I'm unsure how to fix.

I guess they could come from "Context".
I don't obviously see anything else in core that could be used at this second.

Which would mean something like:

RequestContext::getMain()->getUser()

In place of the global

Addshore updated the task description. (Show Details)

Note: there are two usages in the entry point which I'm unsure how to fix.

I guess they could come from "Context".
I don't obviously see anything else in core that could be used at this second.
Which would mean something like:

RequestContext::getMain()->getUser()

In place of the global

Yeah, that's also the only alternative I can think of, given how early the entry point is executed. Given that RequestContext::getMain is almost the same as $wgUser, I'd suggest waiting; in case some new code introduces an alternative...

Well, RequestContext::getMain is slightly less evil that the global probably.
So I'd go for lets just make that patch and hen resolve this task for now :)

If someone wants to get rid of RequestContext::getMain then that is a whole different kettle of fish to tackle later down the line.

Well, RequestContext::getMain is slightly less evil that the global probably.

Yeah, well, a little bit... I believe the only difference is that, when using RequestContext, any piece of code writing to $wgUser and RequestContext::getMain only has to write to the latter. Aside from this, they're the same thing.

So I'd go for lets just make that patch and hen resolve this task for now :)
If someone wants to get rid of RequestContext::getMain then that is a whole different kettle of fish to tackle later down the line.

Sure :) In places where a User object can be injected, I believe that it's not worth it to use RequestContext::getMain now, and replace it with proper DI later. But, where there's no clear way to inject a User, I think RequestContext::getMain is acceptable.

Change 564975 had a related patch set uploaded (by Silvan Heintze; owner: Silvan Heintze):
[mediawiki/extensions/Wikibase@master] Replace global $wgUser with same user info from RequestContext

https://gerrit.wikimedia.org/r/564975

Change 564975 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Replace $wgUser with user from RequestContext

https://gerrit.wikimedia.org/r/564975

Addshore closed this task as Resolved.Jan 16 2020, 4:27 PM