Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -73,6 +73,7 @@ |
74 | 74 | # Get variables from query string :P |
75 | 75 | $section = $wgRequest->getVal( 'section' ); |
76 | 76 | $preload = $wgRequest->getVal( 'preload' ); |
| 77 | + $undoafter = $wgRequest->getVal( 'undoafter' ); |
77 | 78 | $undo = $wgRequest->getVal( 'undo' ); |
78 | 79 | |
79 | 80 | wfProfileIn( __METHOD__ ); |
— | — | @@ -98,24 +99,26 @@ |
99 | 100 | |
100 | 101 | $text = $this->mArticle->getContent(); |
101 | 102 | |
102 | | - if ( $undo > 0 ) { |
103 | | - #Undoing a specific edit overrides section editing; section-editing |
| 103 | + if ( $undo > 0 && $undo > $undoafter ) { |
| 104 | + # Undoing a specific edit overrides section editing; section-editing |
104 | 105 | # doesn't work with undoing. |
105 | | - $undorev = Revision::newFromId($undo); |
106 | | - $oldrev = $undorev ? $undorev->getPrevious() : null; |
107 | | - |
| 106 | + if ( $undoafter ) { |
| 107 | + $undorev = Revision::newFromId($undo); |
| 108 | + $oldrev = Revision::newFromId($undoafter); |
| 109 | + } else { |
| 110 | + $undorev = Revision::newFromId($undo); |
| 111 | + $oldrev = $undorev ? $undorev->getPrevious() : null; |
| 112 | + } |
| 113 | + |
108 | 114 | #Sanity check, make sure it's the right page. |
109 | 115 | # Otherwise, $text will be left as-is. |
110 | | - if( !is_null($undorev) |
111 | | - && !is_null( $oldrev ) |
112 | | - && $undorev->getPage() == $this->mArticle->getID() ) { |
113 | | - |
| 116 | + if ( !is_null($undorev) && !is_null($oldrev) && $undorev->getPage()==$oldrev->getPage() && $undorev->getPage()==$this->mArticle->getID() ) { |
114 | 117 | $undorev_text = $undorev->getText(); |
115 | | - $oldrev_text = $oldrev->getText(); |
116 | | - $currev_text = $text; |
| 118 | + $oldrev_text = $oldrev->getText(); |
| 119 | + $currev_text = $text; |
117 | 120 | |
118 | 121 | #No use doing a merge if it's just a straight revert. |
119 | | - if ($currev_text != $undorev_text) { |
| 122 | + if ( $currev_text != $undorev_text ) { |
120 | 123 | $result = wfMerge($undorev_text, $oldrev_text, $currev_text, $text); |
121 | 124 | } else { |
122 | 125 | $text = $oldrev_text; |
— | — | @@ -134,7 +137,7 @@ |
135 | 138 | $firstrev = $oldrev->getNext(); |
136 | 139 | # If we just undid one rev, use an autosummary |
137 | 140 | if ( $firstrev->mId == $undo ) { |
138 | | - $this->summary = wfMsgForContent('undo-summary', $undo, $undorev->getUserText()); |
| 141 | + $this->summary = wfMsgForContent('undo-summary', $undo, $undorev->getUserText()); |
139 | 142 | } |
140 | 143 | $this->formtype = 'diff'; |
141 | 144 | } else { |
Index: trunk/phase3/includes/DifferenceEngine.php |
— | — | @@ -546,21 +546,17 @@ |
547 | 547 | $newLink = $this->mNewPage->escapeLocalUrl(); |
548 | 548 | $this->mPagetitle = htmlspecialchars( wfMsg( 'currentrev' ) ); |
549 | 549 | $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit' ); |
550 | | - $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undo=' . $this->mNewid ); |
551 | 550 | |
552 | 551 | $this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a> ($timestamp)" |
553 | | - . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)" |
554 | | - . " (<a href='$newUndo'>" . htmlspecialchars( wfMsg( 'editundo' ) ) . "</a>)"; |
| 552 | + . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)"; |
555 | 553 | |
556 | 554 | } else { |
557 | 555 | $newLink = $this->mNewPage->escapeLocalUrl( 'oldid=' . $this->mNewid ); |
558 | 556 | $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mNewid ); |
559 | | - $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undo=' . $this->mNewid ); |
560 | 557 | $this->mPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $timestamp ) ); |
561 | 558 | |
562 | 559 | $this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a>" |
563 | | - . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)" |
564 | | - . " (<a href='$newUndo'>" . htmlspecialchars( wfMsg( 'editundo' ) ) . "</a>)"; |
| 560 | + . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)"; |
565 | 561 | } |
566 | 562 | |
567 | 563 | // Load the old revision object |
— | — | @@ -591,6 +587,9 @@ |
592 | 588 | $oldEdit = $this->mOldPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mOldid ); |
593 | 589 | $this->mOldtitle = "<a href='$oldLink'>" . htmlspecialchars( wfMsg( 'revisionasof', $t ) ) |
594 | 590 | . "</a> (<a href='$oldEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)"; |
| 591 | + //now that we considered old rev, we can make undo link (bug 8133, multi-edit undo) |
| 592 | + $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undoafter=' . $this->mOldid . '&undo=' . $this->mNewid); |
| 593 | + $this->mNewtitle .= " (<a href='$newUndo'>" . htmlspecialchars( wfMsg( 'editundo' ) ) . "</a>)"; |
595 | 594 | } |
596 | 595 | |
597 | 596 | return true; |