A partial archive of https://discourse-mediawiki.wmflabs.org as of Saturday May 21, 2022.

Remove $_POST from Extension LDAP Authentication

Bbringenberg

Hey there,

I recently adjusted the LDAP Auth Plugin for the needs of our big open source project. We wrote a patch which contains 5 mistakes, 4 of them are just missing spaces, but one is the avoiding of $_POST.

Could you help me with that?
The change would be here: https://gerrit.wikimedia.org/r/#/c/404450/

I guess to use this: https://www.mediawiki.org/wiki/Manual:$wgRequest/de but neither I have a getMain Method nor am I am able to implement the super global variable. I could dig into this, but I would also love to just have it the way you need it.

Greetings from Germany,

Bastian

FlorianSW

It should work, if you use:

global $wgRequest;

// do whatever you need to do on the Request object

The only reason why wgRequest could be null is, if your code runs before the MediaWiki setup is finished (wgRequest is set during the setup). If your code is doing that, you most likely hook into MediaWiki in the wrong way too early :slight_smile:

Like the manual already explains: relying on a global is always a not so good idea, however, if your code does not provide any other access to the current context, it’s kind of ok.

Tgr

The more reliable method is RequestContext::getMain()->getRequest().

Note that LdapAuth is unmaintained (with some people trying to replace it with a set of more focused extensions).