X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Factions%2FRevertAction.php;h=e466e6549aea9c36f9cedb4ba4914307f2d65bfe;hb=bee07f1578675a1ba8fd3248f406495b1b6b5016;hp=8a54c3944d9ab090a39a7c7bf4c58b4ee6b22d9b;hpb=e024b4e93cbfb0f78e88ae9441d58e68dbfb27a9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/actions/RevertAction.php b/includes/actions/RevertAction.php index 8a54c3944d..e466e6549a 100644 --- a/includes/actions/RevertAction.php +++ b/includes/actions/RevertAction.php @@ -53,7 +53,7 @@ class RevertAction extends FormAction { || strpos( $oldimage, '/' ) !== false || strpos( $oldimage, '\\' ) !== false ) { - throw new ErrorPageError( 'internalerror', 'unexpected', array( 'oldimage', $oldimage ) ); + throw new ErrorPageError( 'internalerror', 'unexpected', [ 'oldimage', $oldimage ] ); } $this->oldFile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( @@ -70,7 +70,7 @@ class RevertAction extends FormAction { $form->setWrapperLegendMsg( 'filerevert-legend' ); $form->setSubmitTextMsg( 'filerevert-submit' ); $form->addHiddenField( 'oldimage', $this->getRequest()->getText( 'oldimage' ) ); - $form->setTokenSalt( array( 'revert', $this->getTitle()->getPrefixedDBkey() ) ); + $form->setTokenSalt( [ 'revert', $this->getTitle()->getPrefixedDBkey() ] ); } protected function getFormFields() { @@ -88,8 +88,8 @@ class RevertAction extends FormAction { $siteTime = $wgContLang->time( $ts, false, false ); $tzMsg = $siteTs->getTimezoneMessage()->inContentLanguage()->text(); - return array( - 'intro' => array( + return [ + 'intro' => [ 'type' => 'info', 'vertical-label' => true, 'raw' => true, @@ -99,26 +99,32 @@ class RevertAction extends FormAction { $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText( 'oldimage' ) ), PROTO_CURRENT ) )->parseAsBlock() - ), - 'comment' => array( + ], + 'comment' => [ 'type' => 'text', 'label-message' => 'filerevert-comment', 'default' => $this->msg( 'filerevert-defaultcomment', $siteDate, $siteTime, $tzMsg )->inContentLanguage()->text() - ) - ); + ] + ]; } public function onSubmit( $data ) { $this->useTransactionalTimeLimit(); - $source = $this->page->getFile()->getArchiveVirtualUrl( - $this->getRequest()->getText( 'oldimage' ) - ); + $old = $this->getRequest()->getText( 'oldimage' ); + $localFile = $this->page->getFile(); + $oldFile = OldLocalFile::newFromArchiveName( $this->getTitle(), $localFile->getRepo(), $old ); + + $source = $localFile->getArchiveVirtualUrl( $old ); $comment = $data['comment']; + if ( $localFile->getSha1() === $oldFile->getSha1() ) { + return Status::newFatal( 'filerevert-identical' ); + } + // TODO: Preserve file properties from database instead of reloading from file - return $this->page->getFile()->upload( + return $localFile->upload( $source, $comment, $comment,