Revert r20317 for the moment; incompatible changes to URL parameters for undo
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 27 Mar 2007 21:30:39 +0000 (21:30 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 27 Mar 2007 21:30:39 +0000 (21:30 +0000)
includes/DifferenceEngine.php
includes/EditPage.php

index 884e82a..e6218b6 100644 (file)
@@ -546,17 +546,21 @@ 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 = "<a href='$newLink'>{$this->mPagetitle}</a> ($timestamp)"
-                               . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)";
+                               . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)"
+                               . " (<a href='$newUndo'>" . htmlspecialchars( wfMsg( 'editundo' ) ) . "</a>)";
 
                } 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 = "<a href='$newLink'>{$this->mPagetitle}</a>"
-                               . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)";
+                               . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)"
+                               . " (<a href='$newUndo'>" . htmlspecialchars( wfMsg( 'editundo' ) ) . "</a>)";
                }
 
                // Load the old revision object
@@ -587,9 +591,6 @@ CONTROL;
                        $oldEdit = $this->mOldPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mOldid );
                        $this->mOldtitle = "<a href='$oldLink'>" . htmlspecialchars( wfMsg( 'revisionasof', $t ) )
                                . "</a> (<a href='$oldEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)";
-                       //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 . '&undoto=' . $this->mNewid);
-                       $this->mNewtitle .= " (<a href='$newUndo'>" . htmlspecialchars( wfMsg( 'editundo' ) ) . "</a>)";
                }
 
                return true;
index 48cb471..4246955 100644 (file)
@@ -73,8 +73,7 @@ class EditPage {
                # Get variables from query string :P
                $section = $wgRequest->getVal( 'section' );
                $preload = $wgRequest->getVal( 'preload' );
-               $undoafter = $wgRequest->getVal( 'undoafter' );
-               $undoto = $wgRequest->getVal( 'undoto' );
+               $undo = $wgRequest->getVal( 'undo' );
 
                wfProfileIn( __METHOD__ );
 
@@ -99,21 +98,24 @@ class EditPage {
 
                        $text = $this->mArticle->getContent();
 
-                       if ( $undoafter > 0 && $undoto > $undoafter ) {
+                       if ( $undo > 0 ) {
                                #Undoing a specific edit overrides section editing; section-editing
                                # doesn't work with undoing.
-                               $undorev = Revision::newFromId($undoto);
-                               $oldrev = Revision::newFromId($undoafter);
+                               $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()==$oldrev->getPage() && $undorev->getPage()==$this->mArticle->getID() ) {
+                               if( !is_null($undorev)
+                                       && !is_null( $oldrev )
+                                       && $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;
@@ -131,8 +133,8 @@ class EditPage {
                                        $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-success' ) );
                                        $firstrev = $oldrev->getNext();
                                        # If we just undid one rev, use an autosummary
-                                       if ( $firstrev->mId == $undoto ) {
-                                                       $this->summary = wfMsgForContent('undo-summary', $undoto, $undorev->getUserText());
+                                       if ( $firstrev->mId == $undo ) {
+                                                       $this->summary = wfMsgForContent('undo-summary', $undo, $undorev->getUserText());
                                        }
                                        $this->formtype = 'diff';
                                } else {