Page MenuHomePhabricator

AbuseFilter needs uses of global $wgUser removed
Closed, ResolvedPublic

Description

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

Event Timeline

DannyS712 triaged this task as Medium priority.Mar 3 2020, 4:25 AM
DannyS712 created this task.
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 538706 had a related patch set uploaded (by DannyS712; owner: Daimona Eaytoy):
[mediawiki/extensions/AbuseFilter@master] Kill the last use of wgUser

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

DannyS712 renamed this task from needs uses of global $wgUser removed to AbuseFilter needs uses of global $wgUser removed.Mar 3 2020, 4:26 AM
DannyS712 added a project: Patch-For-Review.

Yeah thanks. That's not going to happen before MW 1.36 though.

Yeah thanks. That's not going to happen before MW 1.36 though.

Would it be possible to use RequestContext::getMain()->getUser() while waiting for the abuse filter blockers to be clear?

Yeah thanks. That's not going to happen before MW 1.36 though.

Would it be possible to use RequestContext::getMain()->getUser() while waiting for the abuse filter blockers to be clear?

In theory yes, but what advantages would it bring?

To move us one step closer to removing reads from $wgUser

To move us one step closer to removing reads from $wgUser

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.

Change 626895 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/AbuseFilter@master] Reduce direct references to $wgUser

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

Change 626895 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@master] Reduce direct references to $wgUser

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

To move us one step closer to removing reads from $wgUser

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() ?

To move us one step closer to removing reads from $wgUser

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() ?

  1. 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;
  2. 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;
  3. 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.

Change 538706 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@master] Almost kill the last use of wgUser

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

Change 649391 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/AbuseFilter@master] AbuseFilterConsequencesTest: stop setting $wgUser

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

Change 649391 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@master] AbuseFilterConsequencesTest: stop setting $wgUser

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