From: daniel Date: Tue, 24 Apr 2012 14:23:55 +0000 (+0200) Subject: replaceSection() should replace entire content if the section id is the empty string. X-Git-Tag: 1.31.0-rc.0~22097^2^2~207 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=168ba919ac79fe31d14ce2c7e9d305bc81d3d699;p=lhc%2Fweb%2Fwiklou.git replaceSection() should replace entire content if the section id is the empty string. --- 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",