Fold RevertFileAction class into RevertAction
authorwithoutaname <drevitchi@gmail.com>
Thu, 10 Jul 2014 01:26:16 +0000 (18:26 -0700)
committerLegoktm <legoktm.wikipedia@gmail.com>
Sun, 13 Jul 2014 02:16:58 +0000 (02:16 +0000)
RevertAction was simply a dummy class for outputting an error message
if the action was not done in the file namespace. I've instead
moved RevertFileAction to RevertAction and threw an exception
from within checkCanExecute().

Change-Id: I7b87de60680009bf4e74d33342cbe81cc0d211b5

RELEASE-NOTES-1.24
includes/AutoLoader.php
includes/actions/RevertAction.php
includes/page/WikiFilePage.php

index 7bfde7d..8011044 100644 (file)
@@ -286,6 +286,7 @@ changes to languages because of Bugzilla reports.
 * IPBlockForm - Use SpecialBlock directly
 * WatchlistEditor - Use SpecialEditWatchlist directly
 * FormatExif - Use FormatMetadata directly
+* RevertFileAction - Use RevertAction directly
 
 == Compatibility ==
 
index d54f5f1..c879258 100644 (file)
@@ -226,7 +226,6 @@ $wgAutoloadLocalClasses = array(
        'RawPage' => 'includes/actions/RawAction.php',
        'RenderAction' => 'includes/actions/RenderAction.php',
        'RevertAction' => 'includes/actions/RevertAction.php',
-       'RevertFileAction' => 'includes/actions/RevertAction.php',
        'RevisiondeleteAction' => 'includes/actions/RevisiondeleteAction.php',
        'RollbackAction' => 'includes/actions/RollbackAction.php',
        'SubmitAction' => 'includes/actions/EditAction.php',
index 92428cf..6481630 100644 (file)
  */
 
 /**
- * Dummy class for pages not in NS_FILE
- *
- * @ingroup Actions
- */
-class RevertAction extends Action {
-
-       public function getName() {
-               return 'revert';
-       }
-
-       public function show() {
-               $this->getOutput()->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
-       }
-
-       public function execute() {
-       }
-}
-
-/**
- * Class for pages in NS_FILE
+ * File reversion user interface
  *
  * @ingroup Actions
  */
-class RevertFileAction extends FormAction {
+class RevertAction extends FormAction {
        /**
         * @var OldLocalFile
         */
@@ -62,6 +43,9 @@ class RevertFileAction extends FormAction {
        }
 
        protected function checkCanExecute( User $user ) {
+               if ( $this->getTitle()->getNamespace() !== NS_FILE ) {
+                       throw new ErrorPageError( $this->msg( 'nosuchaction' ), $this->msg( 'nosuchactiontext' ) );
+               }
                parent::checkCanExecute( $user );
 
                $oldimage = $this->getRequest()->getText( 'oldimage' );
index 34f15c3..87cc7ba 100644 (file)
@@ -40,12 +40,6 @@ class WikiFilePage extends WikiPage {
                $this->mRepo = null;
        }
 
-       public function getActionOverrides() {
-               $overrides = parent::getActionOverrides();
-               $overrides['revert'] = 'RevertFileAction';
-               return $overrides;
-       }
-
        /**
         * @param File $file
         */