From c490d265fa711547ff110438540b4f3457079fa2 Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Mon, 11 Dec 2006 09:39:39 +0000 Subject: [PATCH] Per discussion on wikitech-l, add an (undo) link for on-top revisions as well. Also, don't do a merge if (undo) is being used for a straight revert --- includes/DifferenceEngine.php | 4 +++- includes/EditPage.php | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 77fef48f9a..a72f01535f 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -523,9 +523,11 @@ 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( 'editold' ) ) . ")" + . " (" . htmlspecialchars( wfMsg( 'editundo' ) ) . ")"; } else { $newLink = $this->mNewPage->escapeLocalUrl( 'oldid=' . $this->mNewid ); diff --git a/includes/EditPage.php b/includes/EditPage.php index 0d6f34b5b8..9082fd2760 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -109,8 +109,13 @@ class EditPage { $undorev_text = $undorev->getText(); $oldrev_text = $oldrev->getText(); $currev_text = $text; - - $result = wfMerge($undorev_text, $oldrev_text, $currev_text, $text); + + #No use doing a merge if it's just a straight revert. + if ($currev_text != $undorev_text) { + $result = wfMerge($undorev_text, $oldrev_text, $currev_text, $text); + } else { + $result = true; + } if (!$result) { #Undoing failed. Bailing out with regular revision text. -- 2.20.1