Page MenuHomePhabricator

AbuseFilter should provide a way to get WebRequest in custom variable hooks
Open, Needs TriagePublic


See discussion in, it would be good if hooks that want to add a variable depending on the current WebRequest state could access it without relying on global state.

See (now removed) and as examples that use $wgRequest directly.

Event Timeline

This is a bit problematic... AF itself does not have access to the global request when it fires the hook, and accessing the WebRequest in general is not easy (unless you have a ContextSource). Also, I'm not sure what the future of WebRequest is, and whether we should treat it as a value object or as a service (currently it's something hybrid). If it's the former, then MW core hooks should pass it; if the second, then it should not be passed by the hook, but injected into the hook handler.

Most of the hooks I've seen use it as more of a value object, just checking for some query parameter or header. I don't have a great solution either, just wanted to document this pattern is prevalent and would benefit from something better...