X-Git-Url: https://git.heureux-cyclage.org/index.php?a=blobdiff_plain;f=includes%2Factions%2FRollbackAction.php;h=3dc611b1ae41f493a883c5d2b0ac75e33509d2ed;hb=4b282b3ffafce6c8f12bef4e5a7bbb8b80c51571;hp=e32582e5d2a6692170ce029c569992136d806053;hpb=9af38c046c86a51f82891225e3ea6833566302d4;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/actions/RollbackAction.php b/includes/actions/RollbackAction.php index e32582e5d2..3dc611b1ae 100644 --- a/includes/actions/RollbackAction.php +++ b/includes/actions/RollbackAction.php @@ -25,7 +25,7 @@ * * @ingroup Actions */ -class RollbackAction extends FormAction { +class RollbackAction extends FormlessAction { public function getName() { return 'rollback'; @@ -35,37 +35,20 @@ class RollbackAction extends FormAction { return 'rollback'; } - protected function preText() { - return $this->msg( 'confirm-rollback-top' )->parse(); - } - - protected function alterForm( HTMLForm $form ) { - $form->setSubmitTextMsg( 'confirm-rollback-button' ); - $form->setTokenSalt( 'rollback' ); - - // Copy parameters from GET to confirmation form - $from = $this->getRequest()->getVal( 'from' ); - if ( $from === null ) { - throw new BadRequestError( 'rollbackfailed', 'rollback-missingparam' ); - } - foreach ( [ 'from', 'bot', 'hidediff', 'summary' ] as $param ) { - $val = $this->getRequest()->getVal( $param ); - if ( $val !== null ) { - $form->addHiddenField( $param, $val ); - } - } - } + /** + * Temporarily unused message keys due to T88044/T136375: + * - confirm-rollback-top + * - confirm-rollback-button + * - rollbackfailed + * - rollback-missingparam + */ /** - * This must return true so that HTMLForm::show() will not display the form again after - * submission. For rollback, display either the form or the result (success/error) - * not both. - * - * @return bool * @throws ErrorPageError */ - public function onSubmit( $data ) { - $this->useTransactionalTimeLimit(); + public function onView() { + // TODO: use $this->useTransactionalTimeLimit(); when POST only + wfTransactionalTimeLimit(); $request = $this->getRequest(); $user = $this->getUser(); @@ -74,6 +57,9 @@ class RollbackAction extends FormAction { if ( $from === null || $from === '' ) { throw new ErrorPageError( 'rollbackfailed', 'rollback-missingparam' ); } + if ( !$rev ) { + throw new ErrorPageError( 'rollbackfailed', 'rollback-missingrevision' ); + } if ( $from !== $rev->getUserText() ) { throw new ErrorPageError( 'rollbackfailed', 'alreadyrolled', [ $this->getTitle()->getPrefixedText(), @@ -86,8 +72,7 @@ class RollbackAction extends FormAction { $errors = $this->page->doRollback( $from, $request->getText( 'summary' ), - // Provided by HTMLForm - $request->getVal( 'wpEditToken' ), + $request->getVal( 'token' ), $request->getBool( 'bot' ), $data, $this->getUser() @@ -115,7 +100,7 @@ class RollbackAction extends FormAction { } } - return true; + return; } # NOTE: Permission errors already handled by Action::checkExecute. @@ -160,12 +145,7 @@ class RollbackAction extends FormAction { ); $de->showDiff( '', '' ); } - return true; - } - - public function onSuccess() { - // Required by parent class, but redundant because onSubmit already shows - // the success message when needed. + return; } protected function getDescription() {