* (bug 6295) Add a 'revision patching' functionality, where an edit can be undone (with a functionality similar to diff rev1 rev2 | patch -R rev3 -o rev3). This is triggered by including &undo=revid in an edit URL. A link to a URL that will undo a given edit is shown on NEW NON-CURRENT revision headers on diff pages.
This commit is contained in:
parent
ec83ea5ac9
commit
f062b09dc3
4 changed files with 32 additions and 3 deletions
|
|
@ -219,6 +219,10 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
|
|||
behavior when keys already exist on add (instead of dying with an error...)
|
||||
* Add a hook 'UploadForm:initial' before the upload form is generated, and two
|
||||
member variable for text injection into the form, which can be filled by the hooks.
|
||||
* (bug 6295) Add a "revision patching" functionality, where an edit can be undone
|
||||
(with a functionality similar to diff rev1 rev2 | patch -R rev3 -o rev3).
|
||||
This is triggered by including &undo=revid in an edit URL. A link to a URL
|
||||
that will undo a given edit is shown on NEW NON-CURRENT revision headers on diff pages.
|
||||
|
||||
== Languages updated ==
|
||||
|
||||
|
|
|
|||
|
|
@ -504,10 +504,12 @@ CONTROL;
|
|||
} 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 = "<strong><a href='$newLink'>{$this->mPagetitle}</a></strong>"
|
||||
. " (<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
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ class EditPage {
|
|||
# Get variables from query string :P
|
||||
$section = $wgRequest->getVal( 'section' );
|
||||
$preload = $wgRequest->getVal( 'preload' );
|
||||
$undo = $wgRequest->getVal( 'undo' );
|
||||
|
||||
wfProfileIn( __METHOD__ );
|
||||
|
||||
|
|
@ -93,8 +94,29 @@ class EditPage {
|
|||
// information.
|
||||
|
||||
$text = $this->mArticle->getContent();
|
||||
|
||||
if( $section != '' ) {
|
||||
|
||||
if ( $undo > 0 ) {
|
||||
#Undoing a specific edit overrides section editing; section-editing
|
||||
# doesn't work with undoing.
|
||||
$undorev = Revision::newFromId($undo);
|
||||
$oldrev = $undorev->getPrevious();
|
||||
|
||||
#Sanity check, make sure it's the right page.
|
||||
# Otherwise, $text will be left as-is.
|
||||
if ($undorev->getPage() == $this->mArticle->getID()) {
|
||||
$undorev_text = $undorev->getText();
|
||||
$oldrev_text = $oldrev->getText();
|
||||
$currev_text = $text;
|
||||
|
||||
$result = wfMerge($undorev_text, $oldrev_text, $currev_text, &$text);
|
||||
|
||||
if (!$result) {
|
||||
#Undoing failed. Bailing out with regular revision text.
|
||||
$text = $currev_text;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( $section != '' ) {
|
||||
if( $section == 'new' ) {
|
||||
$text = $this->getPreloadedText( $preload );
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1082,6 +1082,7 @@ is placed by the site operators.",
|
|||
'selectnewerversionfordiff' => 'Select a newer version for comparison',
|
||||
'selectolderversionfordiff' => 'Select an older version for comparison',
|
||||
'compareselectedversions' => 'Compare selected versions',
|
||||
'editundo' => 'undo',
|
||||
|
||||
# Search results
|
||||
#
|
||||
|
|
|
|||
Loading…
Reference in a new issue