replaceSection() should replace entire content if the section id is the empty string.
authordaniel <daniel.kinzler@wikimedia.de>
Tue, 24 Apr 2012 14:23:55 +0000 (16:23 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Tue, 24 Apr 2012 14:23:55 +0000 (16:23 +0200)
includes/Content.php
tests/phpunit/includes/WikitextContentTest.php

index 793e62b..41b7ac3 100644 (file)
@@ -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 ) ) ) {
index c570024..96eea7a 100644 (file)
@@ -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",