Page MenuHomePhabricator

Stop using $wgUser in Wikibase
Closed, ResolvedPublic

Event Timeline

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.

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

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

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

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