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, $mediaWiki; |
| 2384 | + global $wgContLang; |
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( $mediaWiki->getPerformedAction() ); |
| 2430 | + $bodyAttrs['class'] .= ' action-' . Sanitizer::escapeClass( Action::getActionName( $this->getContext() ) ); |
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, $mediaWiki; |
| 2832 | + global $wgUseAjax, $wgEnableMWSuggest; |
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' => $mediaWiki->getPerformedAction(), |
| 2868 | + 'wgAction' => Action::getActionName( $this->getContext() ), |
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,11 +34,6 @@ |
35 | 35 | private $context; |
36 | 36 | |
37 | 37 | /** |
38 | | - * @var string |
39 | | - */ |
40 | | - private $performedAction = 'nosuchaction'; |
41 | | - |
42 | | - /** |
43 | 38 | * @param $x null|WebRequest |
44 | 39 | * @return WebRequest |
45 | 40 | */ |
— | — | @@ -81,6 +76,7 @@ |
82 | 77 | $request = $this->context->getRequest(); |
83 | 78 | $curid = $request->getInt( 'curid' ); |
84 | 79 | $title = $request->getVal( 'title' ); |
| 80 | + $action = $request->getVal( 'action', 'view' ); |
85 | 81 | |
86 | 82 | if ( $request->getCheck( 'search' ) ) { |
87 | 83 | // Compatibility with old search URLs which didn't use Special:Search |
— | — | @@ -90,7 +86,7 @@ |
91 | 87 | } elseif ( $curid ) { |
92 | 88 | // URLs like this are generated by RC, because rc_title isn't always accurate |
93 | 89 | $ret = Title::newFromID( $curid ); |
94 | | - } elseif ( $title == '' && $this->getAction() != 'delete' ) { |
| 90 | + } elseif ( $title == '' && $action != 'delete' ) { |
95 | 91 | $ret = Title::newMainPage(); |
96 | 92 | } else { |
97 | 93 | $ret = Title::newFromURL( $title ); |
— | — | @@ -310,40 +306,17 @@ |
311 | 307 | } |
312 | 308 | |
313 | 309 | /** |
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". |
| 310 | + * Returns the name of the action that will be executed. |
317 | 311 | * |
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 | | - * |
323 | 312 | * @return string: action |
324 | 313 | */ |
325 | 314 | public function getAction() { |
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'; |
| 315 | + static $action = null; |
| 316 | + |
| 317 | + if ( $action === null ) { |
| 318 | + $action = Action::getActionName( $this->context ); |
334 | 319 | } |
335 | 320 | |
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 | | - |
348 | 321 | return $action; |
349 | 322 | } |
350 | 323 | |
— | — | @@ -510,14 +483,12 @@ |
511 | 484 | |
512 | 485 | $action = Action::factory( $act, $article ); |
513 | 486 | if ( $action instanceof Action ) { |
514 | | - $this->performedAction = $act; |
515 | 487 | $action->show(); |
516 | 488 | wfProfileOut( __METHOD__ ); |
517 | 489 | return; |
518 | 490 | } |
519 | 491 | |
520 | 492 | if ( wfRunHooks( 'UnknownAction', array( $act, $article ) ) ) { |
521 | | - $this->performedAction = 'nosuchaction'; |
522 | 493 | $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); |
523 | 494 | } |
524 | 495 | |
— | — | @@ -525,18 +496,6 @@ |
526 | 497 | } |
527 | 498 | |
528 | 499 | /** |
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 | | - /** |
541 | 500 | * Run the current MediaWiki instance |
542 | 501 | * index.php just calls this |
543 | 502 | */ |
Index: trunk/phase3/includes/Action.php |
— | — | @@ -87,6 +87,45 @@ |
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 | + /** |
91 | 130 | * Check if a given action is recognised, even if it's disabled |
92 | 131 | * |
93 | 132 | * @param $name String: name of an action |