From 4831df5182e798abb0b17b2e628a743cfa4c664d Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 17 Jan 2012 23:07:15 +0000 Subject: [PATCH] Reverted r109223 per CR --- includes/Action.php | 39 ----------------------------- includes/OutputPage.php | 8 +++--- includes/Wiki.php | 55 +++++++++++++++++++++++++++++++++++------ 3 files changed, 52 insertions(+), 50 deletions(-) diff --git a/includes/Action.php b/includes/Action.php index 08179d6b84..d81d2fe374 100644 --- a/includes/Action.php +++ b/includes/Action.php @@ -86,45 +86,6 @@ abstract class Action { return $class; } - /** - * Get the action that will be executed, not necessarily the one passed - * passed through the "action" request parameter. Actions disabled in - * $wgDisabledActions will be replaced by "nosuchaction". - * - * @param $context IContextSource - * @return string: action name - */ - public final static function getActionName( IContextSource $context ) { - global $wgDisabledActions; - - $request = $context->getRequest(); - $actionName = $request->getVal( 'action', 'view' ); - - // Check for disabled actions - if ( in_array( $actionName, $wgDisabledActions ) ) { - $actionName = 'nosuchaction'; - } - - // Workaround for bug #20966: inability of IE to provide an action dependent - // on which submit button is clicked. - if ( $actionName === 'historysubmit' ) { - if ( $request->getBool( 'revisiondelete' ) ) { - $actionName = 'revisiondelete'; - } else { - $actionName = 'view'; - } - } elseif ( $actionName == 'editredlink' ) { - $actionName = 'edit'; - } - - $action = Action::factory( $actionName, $context->getWikiPage() ); - if ( $action instanceof Action ) { - return $action->getName(); - } - - return 'nosuchaction'; - } - /** * Check if a given action is recognised, even if it's disabled * diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 2cef51c5bb..9c46ff8529 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2380,7 +2380,7 @@ $templates * @return String: The doctype, opening , and head element. */ public function headElement( Skin $sk, $includeStyle = true ) { - global $wgContLang; + global $wgContLang, $mediaWiki; $userdir = $this->getLanguage()->getDir(); $sitedir = $wgContLang->getDir(); @@ -2426,7 +2426,7 @@ $templates } $bodyAttrs['class'] .= ' ' . $sk->getPageClasses( $this->getTitle() ); $bodyAttrs['class'] .= ' skin-' . Sanitizer::escapeClass( $sk->getSkinName() ); - $bodyAttrs['class'] .= ' action-' . Sanitizer::escapeClass( Action::getActionName( $this->getContext() ) ); + $bodyAttrs['class'] .= ' action-' . Sanitizer::escapeClass( $mediaWiki->getPerformedAction() ); $sk->addToBodyAttributes( $this, $bodyAttrs ); // Allow skins to add body attributes they need wfRunHooks( 'OutputPageBodyAttributes', array( $this, $sk, &$bodyAttrs ) ); @@ -2828,7 +2828,7 @@ $templates * @return array */ public function getJSVars() { - global $wgUseAjax, $wgEnableMWSuggest; + global $wgUseAjax, $wgEnableMWSuggest, $mediaWiki; $title = $this->getTitle(); $ns = $title->getNamespace(); @@ -2864,7 +2864,7 @@ $templates 'wgCurRevisionId' => $title->getLatestRevID(), 'wgArticleId' => $title->getArticleId(), 'wgIsArticle' => $this->isArticle(), - 'wgAction' => Action::getActionName( $this->getContext() ), + 'wgAction' => $mediaWiki->getPerformedAction(), 'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(), 'wgUserGroups' => $this->getUser()->getEffectiveGroups(), 'wgCategories' => $this->getCategories(), diff --git a/includes/Wiki.php b/includes/Wiki.php index 13e4f08074..c896f49660 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -33,6 +33,11 @@ class MediaWiki { */ private $context; + /** + * @var string + */ + private $performedAction = 'nosuchaction'; + /** * @param $x null|WebRequest * @return WebRequest @@ -76,7 +81,6 @@ class MediaWiki { $request = $this->context->getRequest(); $curid = $request->getInt( 'curid' ); $title = $request->getVal( 'title' ); - $action = $request->getVal( 'action', 'view' ); if ( $request->getCheck( 'search' ) ) { // Compatibility with old search URLs which didn't use Special:Search @@ -86,7 +90,7 @@ class MediaWiki { } elseif ( $curid ) { // URLs like this are generated by RC, because rc_title isn't always accurate $ret = Title::newFromID( $curid ); - } elseif ( $title == '' && $action != 'delete' ) { + } elseif ( $title == '' && $this->getAction() != 'delete' ) { $ret = Title::newMainPage(); } else { $ret = Title::newFromURL( $title ); @@ -306,15 +310,38 @@ class MediaWiki { } /** - * Returns the name of the action that will be executed. + * Returns the action that will be executed, not necessarily the one passed + * passed through the "action" parameter. Actions disabled in + * $wgDisabledActions will be replaced by "nosuchaction". + * + * The return value is merely a suggestion, not the actually performed action, + * which may be different. The actually performed action is determined by performAction(). + * Requests like action=nonsense will make this function return "nonsense". + * Use getPerformedAction() to get the performed action. * * @return string: action */ public function getAction() { - static $action = null; - - if ( $action === null ) { - $action = Action::getActionName( $this->context ); + global $wgDisabledActions; + + $request = $this->context->getRequest(); + $action = $request->getVal( 'action', 'view' ); + + // Check for disabled actions + if ( in_array( $action, $wgDisabledActions ) ) { + return 'nosuchaction'; + } + + // Workaround for bug #20966: inability of IE to provide an action dependent + // on which submit button is clicked. + if ( $action === 'historysubmit' ) { + if ( $request->getBool( 'revisiondelete' ) ) { + return 'revisiondelete'; + } else { + return 'view'; + } + } elseif ( $action == 'editredlink' ) { + return 'edit'; } return $action; @@ -483,18 +510,32 @@ class MediaWiki { $action = Action::factory( $act, $article ); if ( $action instanceof Action ) { + $this->performedAction = $act; $action->show(); wfProfileOut( __METHOD__ ); return; } if ( wfRunHooks( 'UnknownAction', array( $act, $article ) ) ) { + $this->performedAction = 'nosuchaction'; $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); } wfProfileOut( __METHOD__ ); } + /** + * Returns the real action as determined by performAction. + * Do not use internally in this class as it depends on the actions by this class. + * + * @since 1.19 + * + * @return string: action + */ + public function getPerformedAction() { + return $this->performedAction; + } + /** * Run the current MediaWiki instance * index.php just calls this -- 2.20.1