From 0367d94952c1e37e2cbbdfe9d0542330967df8fd Mon Sep 17 00:00:00 2001 From: withoutaname Date: Wed, 9 Jul 2014 18:26:16 -0700 Subject: [PATCH] Fold RevertFileAction class into RevertAction 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 | 1 + includes/AutoLoader.php | 1 - includes/actions/RevertAction.php | 26 +++++--------------------- includes/page/WikiFilePage.php | 6 ------ 4 files changed, 6 insertions(+), 28 deletions(-) diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index 7bfde7d711..8011044629 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -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 == diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index d54f5f1848..c879258bf1 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -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', diff --git a/includes/actions/RevertAction.php b/includes/actions/RevertAction.php index 92428cf1eb..6481630e11 100644 --- a/includes/actions/RevertAction.php +++ b/includes/actions/RevertAction.php @@ -24,30 +24,11 @@ */ /** - * 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' ); diff --git a/includes/page/WikiFilePage.php b/includes/page/WikiFilePage.php index 34f15c3aa6..87cc7ba52f 100644 --- a/includes/page/WikiFilePage.php +++ b/includes/page/WikiFilePage.php @@ -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 */ -- 2.20.1