* (Bug 14005) editing section 0 of an existing but empty page gives no such section...
authorSam Reed <reedy@users.mediawiki.org>
Sat, 19 Mar 2011 23:23:32 +0000 (23:23 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sat, 19 Mar 2011 23:23:32 +0000 (23:23 +0000)
Tested, with minor tweak. Also removed now un-needed code

Patch by Harry Burt

RELEASE-NOTES
includes/parser/Parser.php

index 815c84e..aecd3bd 100644 (file)
@@ -197,6 +197,8 @@ PHP if you have not done so prior to upgrading MediaWiki.
 * (bug 28034) uploading file to local wiki when file exists on shared repository
   (commons) gives spurious info in the warning message
 * Usernames get lost when selecting different sorts on Special:listfiles
+* (Bug 14005) editing section 0 of an existing but empty page gives no such
+  section error
 
 === API changes in 1.18 ===
 * (bug 26339) Throw warning when truncating an overlarge API result
index 81402e9..48e83d2 100644 (file)
@@ -4943,8 +4943,10 @@ class Parser {
 
                # Find the target section
                if ( $sectionIndex == 0 ) {
-                       # Section zero doesn't nest, level=big
-                       $targetLevel = 1000;
+                       if ( !$node ) {
+                               # The page definitely exists - we checked that earlier - so it must be blank: see bug #14005
+                               return $text;
+                       }
                } else {
                        while ( $node ) {
                                if ( $node->getName() === 'h' ) {