r20785 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20784‎ | r20785 | r20786 >
Date:19:41, 28 March 2007
Author:aaron
Status:old
Tags:
Comment:
*Re-add r20317 with support for older URL param, rename "undoto" to just "undo"
Modified paths:
  • /trunk/phase3/includes/DifferenceEngine.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/EditPage.php
@@ -73,6 +73,7 @@
7474 # Get variables from query string :P
7575 $section = $wgRequest->getVal( 'section' );
7676 $preload = $wgRequest->getVal( 'preload' );
 77+ $undoafter = $wgRequest->getVal( 'undoafter' );
7778 $undo = $wgRequest->getVal( 'undo' );
7879
7980 wfProfileIn( __METHOD__ );
@@ -98,24 +99,26 @@
99100
100101 $text = $this->mArticle->getContent();
101102
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
104105 # 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+
108114 #Sanity check, make sure it's the right page.
109115 # 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() ) {
114117 $undorev_text = $undorev->getText();
115 - $oldrev_text = $oldrev->getText();
116 - $currev_text = $text;
 118+ $oldrev_text = $oldrev->getText();
 119+ $currev_text = $text;
117120
118121 #No use doing a merge if it's just a straight revert.
119 - if ($currev_text != $undorev_text) {
 122+ if ( $currev_text != $undorev_text ) {
120123 $result = wfMerge($undorev_text, $oldrev_text, $currev_text, $text);
121124 } else {
122125 $text = $oldrev_text;
@@ -134,7 +137,7 @@
135138 $firstrev = $oldrev->getNext();
136139 # If we just undid one rev, use an autosummary
137140 if ( $firstrev->mId == $undo ) {
138 - $this->summary = wfMsgForContent('undo-summary', $undo, $undorev->getUserText());
 141+ $this->summary = wfMsgForContent('undo-summary', $undo, $undorev->getUserText());
139142 }
140143 $this->formtype = 'diff';
141144 } else {
Index: trunk/phase3/includes/DifferenceEngine.php
@@ -546,21 +546,17 @@
547547 $newLink = $this->mNewPage->escapeLocalUrl();
548548 $this->mPagetitle = htmlspecialchars( wfMsg( 'currentrev' ) );
549549 $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit' );
550 - $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undo=' . $this->mNewid );
551550
552551 $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>)";
555553
556554 } else {
557555 $newLink = $this->mNewPage->escapeLocalUrl( 'oldid=' . $this->mNewid );
558556 $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mNewid );
559 - $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undo=' . $this->mNewid );
560557 $this->mPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $timestamp ) );
561558
562559 $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>)";
565561 }
566562
567563 // Load the old revision object
@@ -591,6 +587,9 @@
592588 $oldEdit = $this->mOldPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mOldid );
593589 $this->mOldtitle = "<a href='$oldLink'>" . htmlspecialchars( wfMsg( 'revisionasof', $t ) )
594590 . "</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>)";
595594 }
596595
597596 return true;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r20317* Enable multi-edit undo (bug 8133)aaron23:03, 10 March 2007