From 45b3ac166d86c7c93d1b2298c733c83ce8b85844 Mon Sep 17 00:00:00 2001 From: Wil Mahan Date: Sun, 19 Sep 2004 20:58:10 +0000 Subject: [PATCH] Fix bug 56, which causes sections to be dropped or duplicated in edit conflicts during section editing. --- includes/Article.php | 18 +++++++++++++++--- includes/EditPage.php | 10 ++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 5245e162b6..64a4095401 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -942,9 +942,21 @@ class Article { /** * Side effects: loads last edit */ - function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = '') { - $this->loadLastEdit(); - $oldtext = $this->getContent( true ); + function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = '', $edittime = NULL) { + if(is_null($edittime)) { + $this->loadLastEdit(); + $oldtext = $this->getContent( true ); + } else { + $dbw =& wfGetDB( DB_MASTER ); + $ns = $this->mTitle->getNamespace(); + $title = $this->mTitle->getDBkey(); + $obj = $dbw->getArray( 'old', + array( 'old_text','old_flags'), + array( 'old_namespace' => $ns, 'old_title' => $title, + 'old_timestamp' => $dbw->timestamp($edittime)), + $fname ); + $oldtext = Article::getRevisionText( $obj ); + } if ($section != '') { if($section=='new') { if($summary) $subject="== {$summary} ==\n\n"; diff --git a/includes/EditPage.php b/includes/EditPage.php index 7c4f0bfefc..1fb7925a7f 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -192,8 +192,14 @@ class EditPage { } $userid = $wgUser->getID(); - $text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded( - $this->section, $this->textbox1, $this->summary); + if ( $isConflict) { + $text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded( + $this->section, $this->textbox1, $this->summary, $this->edittime); + } + else { + $text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded( + $this->section, $this->textbox1, $this->summary); + } # Suppress edit conflict with self if ( ( 0 != $userid ) && ( $this->mArticle->getUser() == $userid ) ) { -- 2.20.1