From fdeeaf043d0fdd07ae0b3081b8b34232207200a3 Mon Sep 17 00:00:00 2001 From: aude Date: Wed, 24 Oct 2012 20:28:07 +0000 Subject: [PATCH] (bug 41352) restore pre-ContentHandler version of mergeChangesInto() New implementation using ContentHandler is buggy and needs repair Change-Id: I4c2055bed3e660be255621e4d476d7c489f4c371 --- includes/EditPage.php | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index e4759fa977..7ebcde0faa 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1469,10 +1469,10 @@ class EditPage { $content = $textbox_content; // do not try to merge here! } elseif ( $this->isConflict ) { # Attempt merge - if ( $this->mergeChangesIntoContent( $textbox_content ) ) { + if ( $this->mergeChangesInto( $content ) ) { // Successful merge! Maybe we should tell the user the good news? $this->isConflict = false; - $content = $textbox_content; + $content = $this->toEditContent( $content ); wfDebug( __METHOD__ . ": Suppressing edit conflict, successful merge.\n" ); } else { $this->section = ''; @@ -1660,15 +1660,37 @@ class EditPage { function mergeChangesInto( &$editText ){ ContentHandler::deprecated( __METHOD__, "1.21" ); - $editContent = $this->toEditContent( $editText ); + wfProfileIn( __METHOD__ ); + + $db = wfGetDB( DB_MASTER ); + + // This is the revision the editor started from + $baseRevision = $this->getBaseRevision(); + if ( is_null( $baseRevision ) ) { + wfProfileOut( __METHOD__ ); + return false; + } + $baseText = $baseRevision->getText(); + + // The current state, we want to merge updates into it + $currentRevision = Revision::loadFromTitle( $db, $this->mTitle ); + if ( is_null( $currentRevision ) ) { + wfProfileOut( __METHOD__ ); + return false; + } + $currentText = $currentRevision->getText(); - $ok = $this->mergeChangesIntoContent( $editContent ); + $result = ''; + $editText = $this->toEditText( $editText ); - if ( $ok ) { - $editText = $this->toEditText( $editContent ); + if ( wfMerge( $baseText, $editText, $currentText, $result ) ) { + $editText = $result; + wfProfileOut( __METHOD__ ); return true; + } else { + wfProfileOut( __METHOD__ ); + return false; } - return false; } /** -- 2.20.1