!$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',
$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 );
}
// 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;
}
*
* @param string|null|bool $text Text to unserialize
* @return Content|bool|null The content object created from $text. If $text was false
- * or null, false resp. null will be returned instead.
+ * or null, then false or null will be returned instead.
*
* @throws MWException If unserializing the text results in a Content
* object that is not an instance of TextContent and