Extension talk:UrlGetParameters

In some cases, parameters may be passed by POST method. Under that situation, this code would not work properly.

In order to solve this issue, we can use the $wgRequest->data array instead of _GET one. The $wgRequest->data array is the concatenation of _POST and _GET one.

The affected function is urlGetParameters_Render and the code would be patched as

Creating link
Could you please show how to create a link that would call a page with such parameters? My attempt caused MediaWiki to create RedLinks, because it decided that the target page didn't exist...

>> You can use Extension:AllowGetParamsInWikilinks

>> If you need POST parameters, you should use a form

Cache issues
If you use this extension, you may have cache issues thus not getting the desired result. You can disable the cache when calling this extension.

The affected function is urlGetParameters_Render and the code would be re-patched (using the previous suggestion) as

Problem solved after installing Winter
I had problems getting a paramter using [ link]

Test after click: After installing Winter it worked by adding. Just wanted leave that note for others. Cheers, very useful extension :) --Subfader 14:51, 28 May 2009 (UTC)

NoCache
First of all, can't this be fixed so that you don't need to disable cache for the page using UrlGetParameters??? Extension:Winter is a very bad recommendation. Not only that it's a 76 KB monster, it also can f*** up other parser functions. Installing WInter just to use is not worth it. I would recommend Extension:MagicNoCache (not tested) or Extension:Variables with 3 simple lines you can add or what ever name you prefer:

case MAG_NOCACHE: $parser->disableCache; # Mark this content as uncacheable break; --Subfader 23:11, 3 June 2009 (UTC)
 * Just a note.. Winter does not "fuck up" parser functions. Both of them can be used on the same page, they just might have unexpected results when you use them together.  Another note, Winter provides access to the URL GET parameters, so if you have installed Winter, you don't actually need to install this extension.  But I do agree with Subfader in one aspect: Winter is not necessarily the best solution if you simply need to disable caching since it is an entire scripting language. --Frantik 07:38, 24 September 2009 (UTC)

get full url?
WOuld be ace if you'd be able to get the fullurl with all parameters. --Subfader 20:01, 15 July 2009 (UTC)


 * Yes, that would be an easy workaround for a start! Why can't you get the URL with all parameters? Might be helpful in wikis where it takes the admins a while to install this extension (helpful, indeed! thanks for implementing!) --Achimbode 11:52, 25 March 2011 (UTC)

Error when installed?
Using:-


 * MediaWiki: 1.5.2
 * PHP: 5.2.5 (isapi)
 * MySQL: 4.0.26-nt

I get an error:-

"Fatal error: Call to undefined method Parser::setFunctionHook in C:\Inetpub\wwwroot\wiki\extensions\UrlGetParameters\UrlGetParameters.php on line 15"

Can anyone throw any light on why this is?

Southcot 10:22, 30 July 2009 (UTC)


 * Your MediaWiki version is extremely outdated, consider an upgrade --Subfader 10:32, 30 July 2009 (UTC)

Yep just realised that my quick look at the extension requirements read 1.10 as being 1.1. . Thanks for answering this. Was looking for a kick to get the upgrade done anyway.

Southcot 13:11, 30 July 2009 (UTC)

Performance
I ran into an interesting performance issue that may help people using this extension.

The bottom line is - use #vardefine if you need to evaluate the content of a #urlget many times on a single page (from the Variable extension - http://www.mediawiki.org/wiki/Extension:VariablesExtension ).

I was able to cut down access times of a wiki page from 15s to 3s doing something like :

This example displays the result of a semantic mediawiki query based on the choice of a starting letter for a glossary.

Calls to #var are far more efficient than repeating calls to #urlget.

- Laurent Alquier

Avoid Injection Issues
To avoid code injection using this extension, wouldn't it be better if the returned value was urlencoded to remove any command sequences? For example:

Doesn't work with MW 1.16 beta 3
Hi. I'm using version 1.0.0 of this extension and I get the following error with MW 1.16 beta 3: Fatal error: Cannot access protected property WebRequest::$data in /localhost/wiki/extensions/URLGetParameters/URLGetParameters.php on line 33 Any suggestions? Many thanks mitchelln 15:11, 23 July 2010 (UTC)
 * Fixed! Using the code suggested in above "Avoid Injection Issues" section by the anonymous person. Thanks whoever you are!
 * Full fix:

function urlGetParameters_Render( &$parser ) { //    // Get the parameters that were passed to this function $params = func_get_args; array_shift( $params ); $parser->disableCache; global $wgRequest; if( array_key_exists( $params[0], $_GET ) ){ return rawurlencode($_GET[$params[0]]); } elseif ( count( $params ) > 1 ){ return rawurlencode($params[1]); } else { return ''; }       if(count($params)>1) return $params[1]; return ""; }
 * mitchelln 17:10, 23 July 2010 (UTC)

--- This sorted it for me too thanks for posting.

Southcot 09:19, 16 March 2011 (UTC)

Have noticed that this fix does screw up the display of the default value if it contains formatting such as etc. Better to have it working at some level though.

Southcot 09:40, 16 March 2011 (UTC)

Getting error messages
Hello, I get error messages when trying this om MW 1.16. Anyone else having problems? rotsee 16:39, 3 March 2011 (UTC)
 * Isn't there a  missing at line 10? rotsee 16:45, 3 March 2011 (UTC)


 * Yes, indeed - somehow some bugs got into the code by the time it got into SVN. I believe I just fixed them. Yaron Koren 05:21, 4 March 2011 (UTC)

Is this safe?
I wonder if  is really safe? I think it should use $wgRequest, no? I switched it to  so I can work with the parameters in the wiki page for templates etc. --Subfader (talk) 21:24, 11 March 2012 (UTC)

Default value doesn't work anymore
doesn't return "0" if the pamter "foo" is empty. Any idea what could cause this?

Better Solution for Caching
I think i have a better solution that addresses the issue with caching. Instead of just outright disabling the cache, I would recommend doing something like this: if (isset($params)) { $parser->disableCache; } That should only disable the cache when the parameters are set (IE - when the pf is being called). It shouldn't disable the cache for your entire wiki. Thought that I'd pass this along. If someone wants to incorporate it into the code, feel free. --Duke33 (talk) 01:47, 9 May 2013 (UTC)

Should it still be marked as stable ?
The link provided to download lead to a 404. In the wikimedia code review, I find "abandoned" status. So It seems it's maintained anymore...