Last modified: 2012-12-31 17:15:14 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T39378, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 37378 - mw.util.getParamValue( 'diff' ) !== null
mw.util.getParamValue( 'diff' ) !== null
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
JavaScript (Other open bugs)
1.20.x
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-06 19:04 UTC by Fomafix
Modified: 2012-12-31 17:15 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Fomafix 2012-06-06 19:04:38 UTC
The following links generates all a difference between revisions:

https://www.mediawiki.org/wiki/?diff
https://www.mediawiki.org/wiki/?diff=
https://www.mediawiki.org/wiki/?diff=0
https://www.mediawiki.org/wiki/?dif%66=0

The JavaScript function mw.util.getParamValue( 'diff' ) generates:

mw.util.getParamValue( 'diff', '?diff' )      // null
mw.util.getParamValue( 'diff', '?diff=' )     // ""
mw.util.getParamValue( 'diff', '?diff=0' )    // 0
mw.util.getParamValue( 'diff', '?dif%66=0' )  // null

The suggested usage in https://www.mediawiki.org/wiki/ResourceLoader/Default_modules#getParamValue

mw.util.getParamValue( 'diff' ) !== null

isn't suitable to distinguish between difference and normal view.

It should be possible in JavaScript to get the same result as in PHP.

A possible solution would be to transfer a normalized URL as string or object in a wiki global with the content.
Comment 1 Fomafix 2012-06-06 19:13:26 UTC
This is a similar problem as in Bug 31918.
Comment 2 Fomafix 2012-06-11 08:25:42 UTC
getParamValue() should decodeURIComponent() the keys like the values in the query string.

Expected results:

mw.util.getParamValue( '%', '?%25=p' )  // "p"
mw.util.getParamValue( 'p', '?p=%25' )  // "%"
Comment 3 Krinkle 2012-12-31 17:15:14 UTC
(In reply to comment #0)
> mw.util.getParamValue( 'diff', '?diff' )      // null
> mw.util.getParamValue( 'diff', '?diff=' )     // ""
> mw.util.getParamValue( 'diff', '?diff=0' )    // 0
> mw.util.getParamValue( 'diff', '?dif%66=0' )  // null

These are all returning as expected imho.

One should never use special characters in keys (and no core or extension code does so).

If you need processed values for server-side values, then these should be exposed by the server explicitly to avoid repeating logic. Because some actions or special pages submit (or at least support) them from POST, in which case getParamValue wouldn't get it.

Point being that accessing the url directly for these kind of things is unreliable and incorrect (more duck-punching or repeating internal details than an API. The url is an input method for the wiki, among other input methods. It it not an output method for what the wiki is doing).

So in this case there could be something like mw.action.fields which would contain whatever data the current action is using / exposing (be it GET parameters, POST parameters or other related information to the current action).

The latter is further described in Bug 31918.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links