Page MenuHomePhabricator

Disallow reference to RequestContext in ServiceWiring
Open, Needs TriagePublic

Description

Background:

It is problematic to reference RequestContext in ServiceWiring. These have ocasionally crept back in.

Most recently in the new UrlUtils service (change 776991, which broke wgInternalServer and wgCanonicalServer (ref T325529, T305093), but also introduced:

UrlUtils::FALLBACK_PROTOCOL => RequestContext::getMain()->getRequest()->getProtocol(),

Rather than to keep chasing these, I propose we add a lint check that prevents these. Either CodeSniffer or Phan would work for this one. Usually we prefer Phan when its type related, although given it would have to be done through the singleton RequestContet::getMain it could also be detecteed more easily/quickly through CodeSniffer.

Event Timeline

Change 919221 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@master] [DNM] Throw an exception when accessing RequestContext from a service

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

Change 919221 abandoned by Bartosz Dziewoński:

[mediawiki/core@master] [DNM] Throw an exception when accessing RequestContext from a service

Reason:

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