URL parameter fetching (mediawiki)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

URL parameter fetching (mediawiki)

John Shepherd
Is there a “special” way in mediawiki to get parameters passed by URL or do you just use the conventional PHP way ($_GET)? I am trying to check if “Special:CreateAccount?reason=“ is set/has a value (and what that value is).

Thank you for your assistance, trying to be convention compliant.
-TheSandDoctor

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: URL parameter fetching (mediawiki)

bawolff
MediaWiki coding conventions is to use the WebRequest object.

In the context of a SpecialPage subclass, you would probably do
$this->getRequest()->getVal( 'reason' );   [Note: This combines both POST
and GET values]

See
https://doc.wikimedia.org/mediawiki-core/master/php/classWebRequest.html#a3eecdf9b5d20122630bf5cc9c8506084
for more details.

--
Brian

On Tue, Oct 1, 2019 at 7:51 PM John Shepherd <[hidden email]> wrote:

> Is there a “special” way in mediawiki to get parameters passed by URL or
> do you just use the conventional PHP way ($_GET)? I am trying to check if
> “Special:CreateAccount?reason=“ is set/has a value (and what that value is).
>
> Thank you for your assistance, trying to be convention compliant.
> -TheSandDoctor
>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: URL parameter fetching (mediawiki)

John Shepherd
Thank you for this. I have tried setting my own custom key-value pair (e.g. using $this->getRequest()->setVal( 'reasonConfirm', 1 );    ), but I cannot seem to retrieve it when the page reloads. I've tried both getVal (returns null every time) and getInt (always returns '0') to no avail. Is there a special way to set your own custom variables?

Interestingly, I have also noticed that my return $this-msg() text is no longer displaying at all. When my validation callback is triggered, only the top "There are problems with some of your input." appears. I have checked en.json and can confirm that the message that should be displayed is still present and is properly formatted.

-TheSandDoctor

-----Original Message-----
From: Wikitech-l <[hidden email]> On Behalf Of bawolff
Sent: October 1, 2019 1:12 PM
To: Wikimedia developers <[hidden email]>
Subject: Re: [Wikitech-l] URL parameter fetching (mediawiki)

MediaWiki coding conventions is to use the WebRequest object.

In the context of a SpecialPage subclass, you would probably do
$this->getRequest()->getVal( 'reason' );   [Note: This combines both POST
and GET values]

See
https://doc.wikimedia.org/mediawiki-core/master/php/classWebRequest.html#a3eecdf9b5d20122630bf5cc9c8506084
for more details.

--
Brian

On Tue, Oct 1, 2019 at 7:51 PM John Shepherd <[hidden email]> wrote:

> Is there a “special” way in mediawiki to get parameters passed by URL
> or do you just use the conventional PHP way ($_GET)? I am trying to
> check if “Special:CreateAccount?reason=“ is set/has a value (and what that value is).
>
> Thank you for your assistance, trying to be convention compliant.
> -TheSandDoctor
>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l