Last modified: 2012-01-08 01:35:35 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 T29930, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 27930 - Ablity to get current action (The Right Way)
Ablity to get current action (The Right Way)
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
All All
: Normal enhancement (vote)
: 1.19.0 release
Assigned To: Krinkle
Depends on:
Blocks: 4438 25800
  Show dependency treegraph
Reported: 2011-03-08 10:07 UTC by Krinkle
Modified: 2012-01-08 01:35 UTC (History)
2 users (show)

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


Description Krinkle 2011-03-08 10:07:11 UTC
Request to implement a $wgAction (PHP variable). This will

A) Remove the duplication of code that redoes this in several places throughout the core and possible extensions as well
B) Make it available in CSS (bug 4438)
C) Make it available in JS (replacing the current workaround)

And should:
* Not be dependant on the action-parameter. Instead it should represent what MediaWiki actually does, and, as we know, the action parameter has nothing to do with that in many cases.
** During a view, action-param is almost never 'view'
** During a diff (which isn't an action, it's called "historysubmit"), action is only 'historysubmit' if it came from the history page (if from recentchanges, watchlist or if manaully constructed like: action is wrongly falling back to 'view' )

* Introduce 'diff' as a valid action and it will be implied if there's a diff-parameter just like 'view' is implied.
* Use action=diff on history submit, deprecate/remove 'historysubmit'
Comment 1 Alexandre Emsenhuber [IAlex] 2011-03-08 10:18:04 UTC
For the sake of God, please don't introduce a new global variable that is not a configuration setting; store in OutputPage, WebRequest or anywhere else you like, but not in the global scope.
You may also have a look at MediaWiki::getAction(); it doesn't do exactly what you request, but that's a first step.
Comment 2 Krinkle 2011-03-08 10:37:59 UTC
Sure, sounds good. Changed the summary.
Comment 3 Krinkle 2011-07-12 11:06:05 UTC
So it'd be implemented as something like MediaWiki::getAction or as a public method of a Request or Context object.
Comment 4 DieBuche 2011-07-12 13:28:16 UTC
MediaWiki::getAction() returns the correct action and now writes it back to $wgRequest as well. I opened a separate bug for action diff as Bug 29840

Can this be closed?
Comment 5 Krinkle 2012-01-08 00:36:03 UTC
Sure. If/when we're switching it all to be special pages, we can use SpecialPageName anyway, which is even better and has a canonical variant which is both available in CSS as well as JS.
Comment 6 Krinkle 2012-01-08 01:19:39 UTC
Re-opening. MediaWiki::getAction barely, if anything, better than it was with getValue('action', 'view').

Using $mediaWiki->getAction() to determine mw.config's wgAction property or body class "action-..." is still unreliable as things like "/w/index.php?action=nonsense" will still make MediaWiki::getAction() return "nonsense".

The "real" action is determined in MediaWiki::performAction, which is using MediaWiki::getAction only as a mild suggestion to get started. We need to store the outcome of the performing action somewhere accessible from anywhere.

It is context/request dependent, but unless we can find a better place, how about storing the actual performed action (which will contain "unknownaction" if there was none, i.e. the "default" case of the switch() in MediaWiki:performAction) .. in a field of the MediaWiki instance and using a public getter to retrieve it?
Comment 7 Krinkle 2012-01-08 01:35:13 UTC
Fixed by r108342.

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