From 0fe87673b78482cfe60b02e2937d1284d83ad4d8 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 28 Mar 2007 19:41:53 +0000 Subject: [PATCH] *Re-add r20317 with support for older URL param, rename "undoto" to just "undo" --- includes/DifferenceEngine.php | 11 +++++------ includes/EditPage.php | 29 ++++++++++++++++------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index e6218b6d9c..f91d67f6a8 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -546,21 +546,17 @@ CONTROL; $newLink = $this->mNewPage->escapeLocalUrl(); $this->mPagetitle = htmlspecialchars( wfMsg( 'currentrev' ) ); $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit' ); - $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undo=' . $this->mNewid ); $this->mNewtitle = "{$this->mPagetitle} ($timestamp)" - . " (" . htmlspecialchars( wfMsg( 'editold' ) ) . ")" - . " (" . htmlspecialchars( wfMsg( 'editundo' ) ) . ")"; + . " (" . htmlspecialchars( wfMsg( 'editold' ) ) . ")"; } else { $newLink = $this->mNewPage->escapeLocalUrl( 'oldid=' . $this->mNewid ); $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mNewid ); - $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undo=' . $this->mNewid ); $this->mPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $timestamp ) ); $this->mNewtitle = "{$this->mPagetitle}" - . " (" . htmlspecialchars( wfMsg( 'editold' ) ) . ")" - . " (" . htmlspecialchars( wfMsg( 'editundo' ) ) . ")"; + . " (" . htmlspecialchars( wfMsg( 'editold' ) ) . ")"; } // Load the old revision object @@ -591,6 +587,9 @@ CONTROL; $oldEdit = $this->mOldPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mOldid ); $this->mOldtitle = "" . htmlspecialchars( wfMsg( 'revisionasof', $t ) ) . " (" . htmlspecialchars( wfMsg( 'editold' ) ) . ")"; + //now that we considered old rev, we can make undo link (bug 8133, multi-edit undo) + $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undoafter=' . $this->mOldid . '&undo=' . $this->mNewid); + $this->mNewtitle .= " (" . htmlspecialchars( wfMsg( 'editundo' ) ) . ")"; } return true; diff --git a/includes/EditPage.php b/includes/EditPage.php index 424695583b..e437349ee4 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -73,6 +73,7 @@ class EditPage { # Get variables from query string :P $section = $wgRequest->getVal( 'section' ); $preload = $wgRequest->getVal( 'preload' ); + $undoafter = $wgRequest->getVal( 'undoafter' ); $undo = $wgRequest->getVal( 'undo' ); wfProfileIn( __METHOD__ ); @@ -98,24 +99,26 @@ class EditPage { $text = $this->mArticle->getContent(); - if ( $undo > 0 ) { - #Undoing a specific edit overrides section editing; section-editing + if ( $undo > 0 && $undo > $undoafter ) { + # Undoing a specific edit overrides section editing; section-editing # doesn't work with undoing. - $undorev = Revision::newFromId($undo); - $oldrev = $undorev ? $undorev->getPrevious() : null; - + if ( $undoafter ) { + $undorev = Revision::newFromId($undo); + $oldrev = Revision::newFromId($undoafter); + } else { + $undorev = Revision::newFromId($undo); + $oldrev = $undorev ? $undorev->getPrevious() : null; + } + #Sanity check, make sure it's the right page. # Otherwise, $text will be left as-is. - if( !is_null($undorev) - && !is_null( $oldrev ) - && $undorev->getPage() == $this->mArticle->getID() ) { - + if ( !is_null($undorev) && !is_null($oldrev) && $undorev->getPage()==$oldrev->getPage() && $undorev->getPage()==$this->mArticle->getID() ) { $undorev_text = $undorev->getText(); - $oldrev_text = $oldrev->getText(); - $currev_text = $text; + $oldrev_text = $oldrev->getText(); + $currev_text = $text; #No use doing a merge if it's just a straight revert. - if ($currev_text != $undorev_text) { + if ( $currev_text != $undorev_text ) { $result = wfMerge($undorev_text, $oldrev_text, $currev_text, $text); } else { $text = $oldrev_text; @@ -134,7 +137,7 @@ class EditPage { $firstrev = $oldrev->getNext(); # If we just undid one rev, use an autosummary if ( $firstrev->mId == $undo ) { - $this->summary = wfMsgForContent('undo-summary', $undo, $undorev->getUserText()); + $this->summary = wfMsgForContent('undo-summary', $undo, $undorev->getUserText()); } $this->formtype = 'diff'; } else { -- 2.20.1