See parent task
@Daimona not claiming this since you already have https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/AbuseFilter/+/538706/ pending (with a number of dependencies) - do you want to claim this?
I've updated https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/AbuseFilter/+/538706/ to link to this task instead of the overall T159299
See parent task
|Open||None||T11968 Reduce use of global and public variables|
|Open||None||T159283 Deprecate non-configuration globals|
|Open||DannyS712||T159299 Deprecate and remove $wgUser|
|Resolved||DannyS712||T267861 [GOAL] Emit deprecation warnings reading from $wgUser|
|Resolved||DannyS712||T245959 WMF deployed extensions need uses of global $wgUser removed [tracking]|
|Resolved||Daimona||T246733 AbuseFilter needs uses of global $wgUser removed|
Yes, but in terms of what the code is doing, I don't see any benefit in doing so. Note, it's not bad -- just useless (IMHO). It would still be using the global state, just in a way that looks prettier. Also, I hope to get the proper solution (T213006) done way before $wgUser will be hard-deprecated.
While I know that there has been progress made on T213006, AbuseFilter is one of the few remaining deployed extensions that reads from $wgUser, and while using RequestContext::getMain() may just look prettier, it also allows the hard deprecation to move forward. The use of global state can be cleaned up later with proper injection. So, as a temporary measure, would you be okay with using RequestContext::getMain() ?
- If AbuseFilter is the only thing blocking the deprecation from moving forward then yes, we might switch to RequestContext::getMain; otherwise, I'd rather wait, in case T213006 is done before the other $wgUser consumers are updated;
- I'm not completely sure about what classes exactly are serialized in the DB, what methods these classes are using, etc. So, I think it might be possible to still have code that uses $wgUser even if we remove the use case in AFComputedVariable;
- Adding to 1), keep in mind that any patch touching that code is going to take some time to both the person writing the patch (that might be you), and to whoever has to manually rebase changes to that file. Unless that code is really the only blocker, I'm not sure it's worth the tradeoff
I do not oppose, I just want to make sure that we're not bikeshedding.