Merge "Simplify HTMLTitleTextField::validate"
[lhc/web/wiklou.git] / includes / EditPage.php
index 64b2f01..7384ca2 100644 (file)
@@ -1222,7 +1222,9 @@ class EditPage {
                                                !$undorev->isDeleted( Revision::DELETED_TEXT ) &&
                                                !$oldrev->isDeleted( Revision::DELETED_TEXT )
                                        ) {
-                                               if ( WikiPage::hasDifferencesOutsideMainSlot( $undorev, $oldrev ) ) {
+                                               if ( WikiPage::hasDifferencesOutsideMainSlot( $undorev, $oldrev )
+                                                       || !$this->isSupportedContentModel( $oldrev->getContentModel() )
+                                               ) {
                                                        // Hack for undo while EditPage can't handle multi-slot editing
                                                        $this->context->getOutput()->redirect( $this->mTitle->getFullURL( [
                                                                'action' => 'mcrundo',
@@ -1304,6 +1306,32 @@ class EditPage {
                                                $this->context->msg( 'undo-' . $undoMsg )->plain() . '</div>', true, /* interface */true );
                                }
 
+                               if ( $content === false ) {
+                                       // Hack for restoring old revisions while EditPage
+                                       // can't handle multi-slot editing.
+
+                                       $curRevision = $this->page->getRevision();
+                                       $oldRevision = $this->mArticle->getRevisionFetched();
+
+                                       if ( $curRevision
+                                               && $oldRevision
+                                               && $curRevision->getId() !== $oldRevision->getId()
+                                               && ( WikiPage::hasDifferencesOutsideMainSlot( $oldRevision, $curRevision )
+                                                       || !$this->isSupportedContentModel( $oldRevision->getContentModel() ) )
+                                       ) {
+                                               $this->context->getOutput()->redirect(
+                                                       $this->mTitle->getFullURL(
+                                                               [
+                                                                       'action' => 'mcrrestore',
+                                                                       'restore' => $oldRevision->getId(),
+                                                               ]
+                                                       )
+                                               );
+
+                                               return false;
+                                       }
+                               }
+
                                if ( $content === false ) {
                                        $content = $this->getOriginalContent( $user );
                                }
@@ -1689,7 +1717,7 @@ class EditPage {
                                // is if an extension hook aborted from inside ArticleSave.
                                // Render the status object into $this->hookError
                                // FIXME this sucks, we should just use the Status object throughout
-                               $this->hookError = '<div class="error">' ."\n" . $status->getWikiText() .
+                               $this->hookError = '<div class="error">' . "\n" . $status->getWikiText() .
                                        '</div>';
                                return true;
                }