'MappedIterator' => __DIR__ . '/includes/libs/MappedIterator.php',
'MarkpatrolledAction' => __DIR__ . '/includes/actions/MarkpatrolledAction.php',
'McTest' => __DIR__ . '/maintenance/mctest.php',
+ 'McrRestoreAction' => __DIR__ . '/includes/actions/McrRestoreAction.php',
'McrUndoAction' => __DIR__ . '/includes/actions/McrUndoAction.php',
'MediaHandler' => __DIR__ . '/includes/media/MediaHandler.php',
'MediaHandlerFactory' => __DIR__ . '/includes/media/MediaHandlerFactory.php',
'info' => true,
'markpatrolled' => true,
'mcrundo' => McrUndoAction::class,
+ 'mcrrestore' => McrRestoreAction::class,
'protect' => true,
'purge' => true,
'raw' => true,
!$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 );
}
--- /dev/null
+<?php
+/**
+ * Temporary action for restoring multi-content revisions
+ * @file
+ * @ingroup Actions
+ */
+
+/**
+ * Temporary action for restoring multi-content revisions.
+ *
+ * This is intended to go away when real MCR support is added to EditPage and
+ * the standard revert-by-edit behavior can be implemented there instead.
+ *
+ * @ingroup Actions
+ * @since 1.32
+ * @deprecated since 1.32
+ */
+class McrRestoreAction extends McrUndoAction {
+
+ public function getName() {
+ return 'mcrrestore';
+ }
+
+ public function getDescription() {
+ return '';
+ }
+
+ protected function initFromParameters() {
+ $curRev = $this->page->getRevision();
+ if ( !$curRev ) {
+ throw new ErrorPageError( 'mcrundofailed', 'nopagetext' );
+ }
+ $this->curRev = $curRev->getRevisionRecord();
+ $this->cur = $this->getRequest()->getInt( 'cur', $this->curRev->getId() );
+
+ $this->undo = $this->cur;
+ $this->undoafter = $this->getRequest()->getInt( 'restore' );
+
+ if ( $this->undo == 0 || $this->undoafter == 0 ) {
+ throw new ErrorPageError( 'mcrundofailed', 'mcrundo-missingparam' );
+ }
+ }
+
+ protected function addStatePropagationFields( HTMLForm $form ) {
+ $form->addHiddenField( 'restore', $this->undoafter );
+ $form->addHiddenField( 'cur', $this->curRev->getId() );
+ }
+
+ protected function alterForm( HTMLForm $form ) {
+ parent::alterForm( $form );
+
+ $form->setWrapperLegendMsg( 'confirm-mcrrestore-title' );
+ }
+
+}
*/
class McrUndoAction extends FormAction {
- private $undo = 0, $undoafter = 0, $cur = 0;
+ protected $undo = 0, $undoafter = 0, $cur = 0;
/** @param RevisionRecord|null */
- private $curRev = null;
+ protected $curRev = null;
public function getName() {
return 'mcrundo';
parent::show();
}
- protected function checkCanExecute( User $user ) {
- parent::checkCanExecute( $user );
-
+ protected function initFromParameters() {
$this->undoafter = $this->getRequest()->getInt( 'undoafter' );
$this->undo = $this->getRequest()->getInt( 'undo' );
}
$this->curRev = $curRev->getRevisionRecord();
$this->cur = $this->getRequest()->getInt( 'cur', $this->curRev->getId() );
+ }
+
+ protected function checkCanExecute( User $user ) {
+ parent::checkCanExecute( $user );
+
+ $this->initFromParameters();
$revisionLookup = MediaWikiServices::getInstance()->getRevisionLookup();
'attribs' => Linker::tooltipAndAccesskeyAttribs( 'diff' ),
] );
+ $this->addStatePropagationFields( $form );
+ }
+
+ protected function addStatePropagationFields( HTMLForm $form ) {
$form->addHiddenField( 'undo', $this->undo );
$form->addHiddenField( 'undoafter', $this->undoafter );
$form->addHiddenField( 'cur', $this->curRev->getId() );
"confirm-unwatch-top": "Remove this page from your watchlist?",
"confirm-rollback-button": "OK",
"confirm-rollback-top": "Revert edits to this page?",
+ "confirm-mcrrestore-title": "Restore a revision",
"confirm-mcrundo-title": "Undo a change",
"mcrundofailed": "Undo failed",
"mcrundo-missingparam": "Missing required parameters on request.",
"confirm-unwatch-top": "Used as confirmation message.",
"confirm-rollback-button": "Used as Submit button text.\n{{Identical|OK}}",
"confirm-rollback-top": "Used as confirmation message.",
+ "confirm-mcrrestore-title": "Title for the editless restore form.",
"confirm-mcrundo-title": "Title for the editless undo form.",
"mcrundofailed": "Title of the error page when an editless undo fails.",
"mcrundo-missingparam": "Error displayed when parameters for action=mcrundo are missing",