X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Factions%2FRevertAction.php;h=6481630e11096576ba8489b8b8dfa88d400b583a;hb=64ca212514d48330ff02fdaed34563e0b75e22c4;hp=cdd139e734f1d81f1408c02745e1c95cf1c96f91;hpb=b3d4f5fbcea66ed3935da28014fb6da832091ebf;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/actions/RevertAction.php b/includes/actions/RevertAction.php index cdd139e734..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' ); @@ -86,6 +70,7 @@ class RevertFileAction extends FormAction { $form->setWrapperLegendMsg( 'filerevert-legend' ); $form->setSubmitTextMsg( 'filerevert-submit' ); $form->addHiddenField( 'oldimage', $this->getRequest()->getText( 'oldimage' ) ); + $form->setTokenSalt( array( 'revert', $this->getTitle()->getPrefixedDBkey() ) ); } protected function getFormFields() {