Page MenuHomePhabricator

Reduce use of RequestContext::getMain in MediaWiki core (outside test code)
Open, Needs TriagePublic

Description

This task specifically targets the reduction of RequestContext::getMain outside test code. There are 93 files using RequestContext at the moment:
https://codesearch.wmcloud.org/core/?q=RequestContext%3A%3AgetMain&files=%5C.php&excludeFiles=phpunit

After a quick pass to identify cases where the reference can easily be deprecated or removed, a next step would be to group the remaining use cases to identify how problematic the reference is, and potentially what one would to do to remove the global context reference.

If a class is touched, we should be careful with regard to hook runners, where an extension may read from RequestContext.

I have identified the following callsites as likely simple to adjust, but did not create a change yet (mostly because I want my number of concurrent patchsets overseeable)

See also: T290706: Parser code for special page transclusion replaces main context

Event Timeline

Change #1269057 had a related patch set uploaded (by MGChecker; author: MGChecker):

[mediawiki/core@master] Hard-deprecate calling HTMLForm::loadInputFromParameters without parent

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

Change #1268106 had a related patch set uploaded (by MGChecker; author: MGChecker):

[mediawiki/core@master] Avoid using global request in Rest entry point

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

Change #1268114 had a related patch set uploaded (by MGChecker; author: MGChecker):

[mediawiki/core@master] Remove unreachable RequestContext fallback

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

At the moment, I am referencing this task directly if we have just a single, rather simple isolated change, and create subtasks for things which involve multiple correlated changes.

Once a probable need of bigger refactorings is identified for certain callsites, an individual task should be created.

Change #1268114 merged by jenkins-bot:

[mediawiki/core@master] Remove unreachable RequestContext fallback

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

Change #1269085 had a related patch set uploaded (by MGChecker; author: MGChecker):

[mediawiki/core@master] Get SecurityLogContext from local context if possible

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

Change #1268106 merged by jenkins-bot:

[mediawiki/core@master] Avoid using global request in Rest entry point

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

Change #1269085 merged by jenkins-bot:

[mediawiki/core@master] Get SecurityLogContext from local context if possible

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

Change #1269057 merged by jenkins-bot:

[mediawiki/core@master] Hard-deprecate calling HTMLForm::loadInputFromParameters without parent

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

Change #1272848 had a related patch set uploaded (by MGChecker; author: MGChecker):

[mediawiki/core@master] Deprecate calling UploadBase::checkWarnings without user

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