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