Page MenuHomePhabricator

Ablity to get current action (The Right Way)
Closed, ResolvedPublic


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'

Version: unspecified
Severity: enhancement



Event Timeline

bzimport raised the priority of this task from to Normal.Nov 21 2014, 11:25 PM
bzimport set Reference to bz27930.
Krinkle created this task.Mar 8 2011, 10:07 AM
IAlex added a comment.Mar 8 2011, 10:18 AM

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.

Sure, sounds good. Changed the summary.

So it'd be implemented as something like MediaWiki::getAction or as a public method of a Request or Context object.

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?

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.

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?

Fixed by r108342.