From 5dd2927e94885ccfb5873e73d4f57ab5af416e19 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Sat, 4 Aug 2007 19:15:18 +0000 Subject: [PATCH] * (bug 10805) Fix "undo" link when viewing the diff of the most recent change to a page using "diff=0" * DifferenceEngine::loadRevisionData() wasn't updating $mNewid when loading the newer revision, which doesn't make too much sense if it ends up left as 0 (which is impossible) --- RELEASE-NOTES | 2 ++ includes/DifferenceEngine.php | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3132897757..b491594b08 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -352,6 +352,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Fixed regression in blocking of username '0' * (bug 9437) Don't overwrite edit form submission handler when setting up edit box scroll position preserve/restore behaviour +* (bug 10805) Fix "undo" link when viewing the diff of the most recent + change to a page using "diff=0" == API changes since 1.10 == diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index fbfab343fc..1deabe8810 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -558,16 +558,15 @@ CONTROL; } // Load the new revision object - if( $this->mNewid ) { - $this->mNewRev = Revision::newFromId( $this->mNewid ); - } else { - $this->mNewRev = Revision::newFromTitle( $this->mTitle ); - } - - if( is_null( $this->mNewRev ) ) { + $this->mNewRev = $this->mNewid + ? Revision::newFromId( $this->mNewid ) + : Revision::newFromTitle( $this->mTitle ); + if( !$this->mNewRev instanceof Revision ) return false; - } - + + // Update the new revision ID in case it was 0 (makes life easier doing UI stuff) + $this->mNewid = $this->mNewRev->getId(); + // Set assorted variables $timestamp = $wgLang->timeanddate( $this->mNewRev->getTimestamp(), true ); $this->mNewPage = $this->mNewRev->getTitle(); @@ -616,7 +615,8 @@ 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) + + // Add an "undo" link $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undoafter=' . $this->mOldid . '&undo=' . $this->mNewid); $this->mNewtitle .= " (" . htmlspecialchars( wfMsg( 'editundo' ) ) . ")"; } -- 2.20.1