X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Factions%2FRevertAction.php;h=a914c9b2b384dd55d4167a4ef12b8242621de0f2;hp=c800ce7c3ce055c37559f8635337a0dc2b7302f8;hb=64b83bdb3afd0ee4f8fc1893a865409c198e601e;hpb=96906168cac0e9a7748511b48c369cf22c8406d5 diff --git a/includes/actions/RevertAction.php b/includes/actions/RevertAction.php index c800ce7c3c..a914c9b2b3 100644 --- a/includes/actions/RevertAction.php +++ b/includes/actions/RevertAction.php @@ -66,6 +66,10 @@ class RevertAction extends FormAction { } } + protected function usesOOUI() { + return true; + } + protected function alterForm( HTMLForm $form ) { $form->setWrapperLegendMsg( 'filerevert-legend' ); $form->setSubmitTextMsg( 'filerevert-submit' ); @@ -112,13 +116,19 @@ class RevertAction extends FormAction { 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,