From 168ba919ac79fe31d14ce2c7e9d305bc81d3d699 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 24 Apr 2012 16:23:55 +0200 Subject: [PATCH] replaceSection() should replace entire content if the section id is the empty string. --- includes/Content.php | 4 +++- tests/phpunit/includes/WikitextContentTest.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/Content.php b/includes/Content.php index 793e62b112..41b7ac39a8 100644 --- a/includes/Content.php +++ b/includes/Content.php @@ -541,7 +541,9 @@ class WikitextContent extends TextContent { $oldtext = $this->getNativeData(); $text = $with->getNativeData(); - if ( $section == 'new' ) { + if ( $section === '' ) { + return $with; #XXX: copy first? + } if ( $section == 'new' ) { # Inserting a new section $subject = $sectionTitle ? wfMsgForContent( 'newsectionheaderdefaultlevel', $sectionTitle ) . "\n\n" : ''; if ( wfRunHooks( 'PlaceNewSection', array( $this, $oldtext, $subject, &$text ) ) ) { diff --git a/tests/phpunit/includes/WikitextContentTest.php b/tests/phpunit/includes/WikitextContentTest.php index c570024b6a..96eea7ac0f 100644 --- a/tests/phpunit/includes/WikitextContentTest.php +++ b/tests/phpunit/includes/WikitextContentTest.php @@ -85,7 +85,7 @@ just a test" "", "No more", null, - trim( preg_replace( '/^Intro/sm', 'No more', WikitextContentTest::$sections ) ) + "No more" ), array( WikitextContentTest::$sections, "2", -- 2.20.1