Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -2380,7 +2380,7 @@ |
2381 | 2381 | * @return String: The doctype, opening <html>, and head element. |
2382 | 2382 | */ |
2383 | 2383 | public function headElement( Skin $sk, $includeStyle = true ) { |
2384 | | - global $wgContLang; |
| 2384 | + global $wgContLang, $mediaWiki; |
2385 | 2385 | |
2386 | 2386 | $userdir = $this->getLanguage()->getDir(); |
2387 | 2387 | $sitedir = $wgContLang->getDir(); |
— | — | @@ -2426,7 +2426,7 @@ |
2427 | 2427 | } |
2428 | 2428 | $bodyAttrs['class'] .= ' ' . $sk->getPageClasses( $this->getTitle() ); |
2429 | 2429 | $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() ); |
2431 | 2431 | |
2432 | 2432 | $sk->addToBodyAttributes( $this, $bodyAttrs ); // Allow skins to add body attributes they need |
2433 | 2433 | wfRunHooks( 'OutputPageBodyAttributes', array( $this, $sk, &$bodyAttrs ) ); |
— | — | @@ -2828,7 +2828,7 @@ |
2829 | 2829 | * @return array |
2830 | 2830 | */ |
2831 | 2831 | public function getJSVars() { |
2832 | | - global $wgUseAjax, $wgEnableMWSuggest; |
| 2832 | + global $wgUseAjax, $wgEnableMWSuggest, $mediaWiki; |
2833 | 2833 | |
2834 | 2834 | $title = $this->getTitle(); |
2835 | 2835 | $ns = $title->getNamespace(); |
— | — | @@ -2864,7 +2864,7 @@ |
2865 | 2865 | 'wgCurRevisionId' => $title->getLatestRevID(), |
2866 | 2866 | 'wgArticleId' => $title->getArticleId(), |
2867 | 2867 | 'wgIsArticle' => $this->isArticle(), |
2868 | | - 'wgAction' => Action::getActionName( $this->getContext() ), |
| 2868 | + 'wgAction' => $mediaWiki->getPerformedAction(), |
2869 | 2869 | 'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(), |
2870 | 2870 | 'wgUserGroups' => $this->getUser()->getEffectiveGroups(), |
2871 | 2871 | 'wgCategories' => $this->getCategories(), |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -34,6 +34,11 @@ |
35 | 35 | private $context; |
36 | 36 | |
37 | 37 | /** |
| 38 | + * @var string |
| 39 | + */ |
| 40 | + private $performedAction = 'nosuchaction'; |
| 41 | + |
| 42 | + /** |
38 | 43 | * @param $x null|WebRequest |
39 | 44 | * @return WebRequest |
40 | 45 | */ |
— | — | @@ -76,7 +81,6 @@ |
77 | 82 | $request = $this->context->getRequest(); |
78 | 83 | $curid = $request->getInt( 'curid' ); |
79 | 84 | $title = $request->getVal( 'title' ); |
80 | | - $action = $request->getVal( 'action', 'view' ); |
81 | 85 | |
82 | 86 | if ( $request->getCheck( 'search' ) ) { |
83 | 87 | // Compatibility with old search URLs which didn't use Special:Search |
— | — | @@ -86,7 +90,7 @@ |
87 | 91 | } elseif ( $curid ) { |
88 | 92 | // URLs like this are generated by RC, because rc_title isn't always accurate |
89 | 93 | $ret = Title::newFromID( $curid ); |
90 | | - } elseif ( $title == '' && $action != 'delete' ) { |
| 94 | + } elseif ( $title == '' && $this->getAction() != 'delete' ) { |
91 | 95 | $ret = Title::newMainPage(); |
92 | 96 | } else { |
93 | 97 | $ret = Title::newFromURL( $title ); |
— | — | @@ -306,17 +310,40 @@ |
307 | 311 | } |
308 | 312 | |
309 | 313 | /** |
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". |
311 | 317 | * |
| 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 | + * |
312 | 323 | * @return string: action |
313 | 324 | */ |
314 | 325 | 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'; |
319 | 334 | } |
320 | 335 | |
| 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 | + |
321 | 348 | return $action; |
322 | 349 | } |
323 | 350 | |
— | — | @@ -483,12 +510,14 @@ |
484 | 511 | |
485 | 512 | $action = Action::factory( $act, $article ); |
486 | 513 | if ( $action instanceof Action ) { |
| 514 | + $this->performedAction = $act; |
487 | 515 | $action->show(); |
488 | 516 | wfProfileOut( __METHOD__ ); |
489 | 517 | return; |
490 | 518 | } |
491 | 519 | |
492 | 520 | if ( wfRunHooks( 'UnknownAction', array( $act, $article ) ) ) { |
| 521 | + $this->performedAction = 'nosuchaction'; |
493 | 522 | $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); |
494 | 523 | } |
495 | 524 | |
— | — | @@ -496,6 +525,18 @@ |
497 | 526 | } |
498 | 527 | |
499 | 528 | /** |
| 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 | + /** |
500 | 541 | * Run the current MediaWiki instance |
501 | 542 | * index.php just calls this |
502 | 543 | */ |
Index: trunk/phase3/includes/Action.php |
— | — | @@ -87,45 +87,6 @@ |
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
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 | | - /** |
130 | 91 | * Check if a given action is recognised, even if it's disabled |
131 | 92 | * |
132 | 93 | * @param $name String: name of an action |