r20755 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20754‎ | r20755 | r20756 >
Date:21:30, 27 March 2007
Author:brion
Status:old
Tags:
Comment:
Revert r20317 for the moment; incompatible changes to URL parameters for 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,8 +73,7 @@
7474 # Get variables from query string :P
7575 $section = $wgRequest->getVal( 'section' );
7676 $preload = $wgRequest->getVal( 'preload' );
77 - $undoafter = $wgRequest->getVal( 'undoafter' );
78 - $undoto = $wgRequest->getVal( 'undoto' );
 77+ $undo = $wgRequest->getVal( 'undo' );
7978
8079 wfProfileIn( __METHOD__ );
8180
@@ -99,21 +98,24 @@
10099
101100 $text = $this->mArticle->getContent();
102101
103 - if ( $undoafter > 0 && $undoto > $undoafter ) {
 102+ if ( $undo > 0 ) {
104103 #Undoing a specific edit overrides section editing; section-editing
105104 # 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;
108107
109108 #Sanity check, make sure it's the right page.
110109 # 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+
112114 $undorev_text = $undorev->getText();
113 - $oldrev_text = $oldrev->getText();
114 - $currev_text = $text;
 115+ $oldrev_text = $oldrev->getText();
 116+ $currev_text = $text;
115117
116118 #No use doing a merge if it's just a straight revert.
117 - if ( $currev_text != $undorev_text ) {
 119+ if ($currev_text != $undorev_text) {
118120 $result = wfMerge($undorev_text, $oldrev_text, $currev_text, $text);
119121 } else {
120122 $text = $oldrev_text;
@@ -131,8 +133,8 @@
132134 $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-success' ) );
133135 $firstrev = $oldrev->getNext();
134136 # 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());
137139 }
138140 $this->formtype = 'diff';
139141 } else {
Index: trunk/phase3/includes/DifferenceEngine.php
@@ -546,17 +546,21 @@
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 );
550551
551552 $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>)";
553555
554556 } else {
555557 $newLink = $this->mNewPage->escapeLocalUrl( 'oldid=' . $this->mNewid );
556558 $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mNewid );
 559+ $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undo=' . $this->mNewid );
557560 $this->mPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $timestamp ) );
558561
559562 $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>)";
561565 }
562566
563567 // Load the old revision object
@@ -587,9 +591,6 @@
588592 $oldEdit = $this->mOldPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mOldid );
589593 $this->mOldtitle = "<a href='$oldLink'>" . htmlspecialchars( wfMsg( 'revisionasof', $t ) )
590594 . "</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>)";
594595 }
595596
596597 return true;

Past revisions this follows-up on

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