r109243 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109242‎ | r109243 | r109244 >
Date:23:07, 17 January 2012
Author:aaron
Status:reverted
Tags:bug27930, core 
Comment:
Reverted r109223 per CR
Modified paths:
  • /trunk/phase3/includes/Action.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -2380,7 +2380,7 @@
23812381 * @return String: The doctype, opening <html>, and head element.
23822382 */
23832383 public function headElement( Skin $sk, $includeStyle = true ) {
2384 - global $wgContLang;
 2384+ global $wgContLang, $mediaWiki;
23852385
23862386 $userdir = $this->getLanguage()->getDir();
23872387 $sitedir = $wgContLang->getDir();
@@ -2426,7 +2426,7 @@
24272427 }
24282428 $bodyAttrs['class'] .= ' ' . $sk->getPageClasses( $this->getTitle() );
24292429 $bodyAttrs['class'] .= ' skin-' . Sanitizer::escapeClass( $sk->getSkinName() );
2430 - $bodyAttrs['class'] .= ' action-' . Sanitizer::escapeClass( Action::getActionName( $this->getContext() ) );
 2430+ $bodyAttrs['class'] .= ' action-' . Sanitizer::escapeClass( $mediaWiki->getPerformedAction() );
24312431
24322432 $sk->addToBodyAttributes( $this, $bodyAttrs ); // Allow skins to add body attributes they need
24332433 wfRunHooks( 'OutputPageBodyAttributes', array( $this, $sk, &$bodyAttrs ) );
@@ -2828,7 +2828,7 @@
28292829 * @return array
28302830 */
28312831 public function getJSVars() {
2832 - global $wgUseAjax, $wgEnableMWSuggest;
 2832+ global $wgUseAjax, $wgEnableMWSuggest, $mediaWiki;
28332833
28342834 $title = $this->getTitle();
28352835 $ns = $title->getNamespace();
@@ -2864,7 +2864,7 @@
28652865 'wgCurRevisionId' => $title->getLatestRevID(),
28662866 'wgArticleId' => $title->getArticleId(),
28672867 'wgIsArticle' => $this->isArticle(),
2868 - 'wgAction' => Action::getActionName( $this->getContext() ),
 2868+ 'wgAction' => $mediaWiki->getPerformedAction(),
28692869 'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(),
28702870 'wgUserGroups' => $this->getUser()->getEffectiveGroups(),
28712871 'wgCategories' => $this->getCategories(),
Index: trunk/phase3/includes/Wiki.php
@@ -34,6 +34,11 @@
3535 private $context;
3636
3737 /**
 38+ * @var string
 39+ */
 40+ private $performedAction = 'nosuchaction';
 41+
 42+ /**
3843 * @param $x null|WebRequest
3944 * @return WebRequest
4045 */
@@ -76,7 +81,6 @@
7782 $request = $this->context->getRequest();
7883 $curid = $request->getInt( 'curid' );
7984 $title = $request->getVal( 'title' );
80 - $action = $request->getVal( 'action', 'view' );
8185
8286 if ( $request->getCheck( 'search' ) ) {
8387 // Compatibility with old search URLs which didn't use Special:Search
@@ -86,7 +90,7 @@
8791 } elseif ( $curid ) {
8892 // URLs like this are generated by RC, because rc_title isn't always accurate
8993 $ret = Title::newFromID( $curid );
90 - } elseif ( $title == '' && $action != 'delete' ) {
 94+ } elseif ( $title == '' && $this->getAction() != 'delete' ) {
9195 $ret = Title::newMainPage();
9296 } else {
9397 $ret = Title::newFromURL( $title );
@@ -306,17 +310,40 @@
307311 }
308312
309313 /**
310 - * Returns the name of the action that will be executed.
 314+ * Returns the action that will be executed, not necessarily the one passed
 315+ * passed through the "action" parameter. Actions disabled in
 316+ * $wgDisabledActions will be replaced by "nosuchaction".
311317 *
 318+ * The return value is merely a suggestion, not the actually performed action,
 319+ * which may be different. The actually performed action is determined by performAction().
 320+ * Requests like action=nonsense will make this function return "nonsense".
 321+ * Use getPerformedAction() to get the performed action.
 322+ *
312323 * @return string: action
313324 */
314325 public function getAction() {
315 - static $action = null;
316 -
317 - if ( $action === null ) {
318 - $action = Action::getActionName( $this->context );
 326+ global $wgDisabledActions;
 327+
 328+ $request = $this->context->getRequest();
 329+ $action = $request->getVal( 'action', 'view' );
 330+
 331+ // Check for disabled actions
 332+ if ( in_array( $action, $wgDisabledActions ) ) {
 333+ return 'nosuchaction';
319334 }
320335
 336+ // Workaround for bug #20966: inability of IE to provide an action dependent
 337+ // on which submit button is clicked.
 338+ if ( $action === 'historysubmit' ) {
 339+ if ( $request->getBool( 'revisiondelete' ) ) {
 340+ return 'revisiondelete';
 341+ } else {
 342+ return 'view';
 343+ }
 344+ } elseif ( $action == 'editredlink' ) {
 345+ return 'edit';
 346+ }
 347+
321348 return $action;
322349 }
323350
@@ -483,12 +510,14 @@
484511
485512 $action = Action::factory( $act, $article );
486513 if ( $action instanceof Action ) {
 514+ $this->performedAction = $act;
487515 $action->show();
488516 wfProfileOut( __METHOD__ );
489517 return;
490518 }
491519
492520 if ( wfRunHooks( 'UnknownAction', array( $act, $article ) ) ) {
 521+ $this->performedAction = 'nosuchaction';
493522 $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
494523 }
495524
@@ -496,6 +525,18 @@
497526 }
498527
499528 /**
 529+ * Returns the real action as determined by performAction.
 530+ * Do not use internally in this class as it depends on the actions by this class.
 531+ *
 532+ * @since 1.19
 533+ *
 534+ * @return string: action
 535+ */
 536+ public function getPerformedAction() {
 537+ return $this->performedAction;
 538+ }
 539+
 540+ /**
500541 * Run the current MediaWiki instance
501542 * index.php just calls this
502543 */
Index: trunk/phase3/includes/Action.php
@@ -87,45 +87,6 @@
8888 }
8989
9090 /**
91 - * Get the action that will be executed, not necessarily the one passed
92 - * passed through the "action" request parameter. Actions disabled in
93 - * $wgDisabledActions will be replaced by "nosuchaction".
94 - *
95 - * @param $context IContextSource
96 - * @return string: action name
97 - */
98 - public final static function getActionName( IContextSource $context ) {
99 - global $wgDisabledActions;
100 -
101 - $request = $context->getRequest();
102 - $actionName = $request->getVal( 'action', 'view' );
103 -
104 - // Check for disabled actions
105 - if ( in_array( $actionName, $wgDisabledActions ) ) {
106 - $actionName = 'nosuchaction';
107 - }
108 -
109 - // Workaround for bug #20966: inability of IE to provide an action dependent
110 - // on which submit button is clicked.
111 - if ( $actionName === 'historysubmit' ) {
112 - if ( $request->getBool( 'revisiondelete' ) ) {
113 - $actionName = 'revisiondelete';
114 - } else {
115 - $actionName = 'view';
116 - }
117 - } elseif ( $actionName == 'editredlink' ) {
118 - $actionName = 'edit';
119 - }
120 -
121 - $action = Action::factory( $actionName, $context->getWikiPage() );
122 - if ( $action instanceof Action ) {
123 - return $action->getName();
124 - }
125 -
126 - return 'nosuchaction';
127 - }
128 -
129 - /**
13091 * Check if a given action is recognised, even if it's disabled
13192 *
13293 * @param $name String: name of an action

Follow-up revisions

RevisionCommit summaryAuthorDate
r109678Reinstate r109223 per CR + fixes...krinkle06:57, 21 January 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r109223[Actions] Move action logic out of MediaWiki::getAction/MediaWiki::performAct...krinkle21:49, 17 January 2012

Status & tagging log