Fix bug 56, which causes sections to be dropped or duplicated
authorWil Mahan <wmahan@users.mediawiki.org>
Sun, 19 Sep 2004 20:58:10 +0000 (20:58 +0000)
committerWil Mahan <wmahan@users.mediawiki.org>
Sun, 19 Sep 2004 20:58:10 +0000 (20:58 +0000)
in edit conflicts during section editing.

includes/Article.php
includes/EditPage.php

index 5245e16..64a4095 100644 (file)
@@ -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";
index 7c4f0bf..1fb7925 100644 (file)
@@ -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 ) ) {