Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -33,6 +33,11 @@ |
34 | 34 | */ |
35 | 35 | private $context; |
36 | 36 | |
| 37 | + /** |
| 38 | + * @var string |
| 39 | + */ |
| 40 | + private $peformedAction = 'nosuchaction'; |
| 41 | + |
37 | 42 | public function request( WebRequest $x = null ){ |
38 | 43 | $old = $this->context->getRequest(); |
39 | 44 | $this->context->setRequest( $x ); |
— | — | @@ -296,9 +301,14 @@ |
297 | 302 | /** |
298 | 303 | * Returns the action that will be executed, not necessarily the one passed |
299 | 304 | * passed through the "action" parameter. Actions disabled in |
300 | | - * $wgDisabledActions will be replaced by "nosuchaction" |
| 305 | + * $wgDisabledActions will be replaced by "nosuchaction". |
301 | 306 | * |
302 | | - * @return String: action |
| 307 | + * The return value is merely a suggestion, not the actually performed action, |
| 308 | + * which may be different. The actually performed action is determined by performAction(). |
| 309 | + * Requests like action=nonsense will make this function return "nonsense". |
| 310 | + * Use getPerformedAction() to get the performed action. |
| 311 | + * |
| 312 | + * @return string: action |
303 | 313 | */ |
304 | 314 | public function getAction() { |
305 | 315 | global $wgDisabledActions; |
— | — | @@ -489,6 +499,7 @@ |
490 | 500 | |
491 | 501 | $action = Action::factory( $act, $article ); |
492 | 502 | if ( $action instanceof Action ) { |
| 503 | + $this->performedAction = $act; |
493 | 504 | $action->show(); |
494 | 505 | wfProfileOut( __METHOD__ ); |
495 | 506 | return; |
— | — | @@ -497,12 +508,14 @@ |
498 | 509 | switch( $act ) { |
499 | 510 | case 'view': |
500 | 511 | $output->setSquidMaxage( $wgSquidMaxage ); |
| 512 | + $this->performedAction = $act; |
501 | 513 | $article->view(); |
502 | 514 | break; |
503 | 515 | case 'delete': |
504 | 516 | case 'protect': |
505 | 517 | case 'unprotect': |
506 | 518 | case 'render': |
| 519 | + $this->performedAction = $act; |
507 | 520 | $article->$act(); |
508 | 521 | break; |
509 | 522 | case 'submit': |
— | — | @@ -513,6 +526,7 @@ |
514 | 527 | // Continue... |
515 | 528 | case 'edit': |
516 | 529 | if ( wfRunHooks( 'CustomEditor', array( $article, $user ) ) ) { |
| 530 | + $this->performedAction = 'edit'; |
517 | 531 | if ( ExternalEdit::useExternalEngine( $this->context, 'edit' ) |
518 | 532 | && $act == 'edit' && !$request->getVal( 'section' ) |
519 | 533 | && !$request->getVal( 'oldid' ) ) |
— | — | @@ -527,6 +541,7 @@ |
528 | 542 | break; |
529 | 543 | default: |
530 | 544 | if ( wfRunHooks( 'UnknownAction', array( $act, $article ) ) ) { |
| 545 | + $this->performedAction = 'nosuchaction'; |
531 | 546 | $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); |
532 | 547 | } |
533 | 548 | } |
— | — | @@ -534,6 +549,16 @@ |
535 | 550 | } |
536 | 551 | |
537 | 552 | /** |
| 553 | + * Returns the real action as determined by performAction. |
| 554 | + * Do not use internally in this class as it depends on the actions by this class. |
| 555 | + * |
| 556 | + * @return string: action |
| 557 | + */ |
| 558 | + public function getPerformedAction(){ |
| 559 | + return $this->performedAction; |
| 560 | + } |
| 561 | + |
| 562 | + /** |
538 | 563 | * Run the current MediaWiki instance |
539 | 564 | * index.php just calls this |
540 | 565 | */ |