r5306 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r5305‎ | r5306 | r5307 >
Date:20:58, 19 September 2004
Author:wmahan
Status:old
Tags:
Comment:
Fix bug 56, which causes sections to be dropped or duplicated
in edit conflicts during section editing.
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -942,9 +942,21 @@
943943 /**
944944 * Side effects: loads last edit
945945 */
946 - function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = '') {
947 - $this->loadLastEdit();
948 - $oldtext = $this->getContent( true );
 946+ function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = '', $edittime = NULL) {
 947+ if(is_null($edittime)) {
 948+ $this->loadLastEdit();
 949+ $oldtext = $this->getContent( true );
 950+ } else {
 951+ $dbw =& wfGetDB( DB_MASTER );
 952+ $ns = $this->mTitle->getNamespace();
 953+ $title = $this->mTitle->getDBkey();
 954+ $obj = $dbw->getArray( 'old',
 955+ array( 'old_text','old_flags'),
 956+ array( 'old_namespace' => $ns, 'old_title' => $title,
 957+ 'old_timestamp' => $dbw->timestamp($edittime)),
 958+ $fname );
 959+ $oldtext = Article::getRevisionText( $obj );
 960+ }
949961 if ($section != '') {
950962 if($section=='new') {
951963 if($summary) $subject="== {$summary} ==\n\n";
Index: trunk/phase3/includes/EditPage.php
@@ -192,8 +192,14 @@
193193 }
194194 $userid = $wgUser->getID();
195195
196 - $text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded(
197 - $this->section, $this->textbox1, $this->summary);
 196+ if ( $isConflict) {
 197+ $text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded(
 198+ $this->section, $this->textbox1, $this->summary, $this->edittime);
 199+ }
 200+ else {
 201+ $text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded(
 202+ $this->section, $this->textbox1, $this->summary);
 203+ }
198204 # Suppress edit conflict with self
199205
200206 if ( ( 0 != $userid ) && ( $this->mArticle->getUser() == $userid ) ) {

Status & tagging log