r84357 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84356‎ | r84357 | r84358 >
Date:23:23, 19 March 2011
Author:reedy
Status:reverted (Comments)
Tags:
Comment:
* (Bug 14005) editing section 0 of an existing but empty page gives no such section error

Tested, with minor tweak. Also removed now un-needed code

Patch by Harry Burt
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -4943,8 +4943,10 @@
49444944
49454945 # Find the target section
49464946 if ( $sectionIndex == 0 ) {
4947 - # Section zero doesn't nest, level=big
4948 - $targetLevel = 1000;
 4947+ if ( !$node ) {
 4948+ # The page definitely exists - we checked that earlier - so it must be blank: see bug #14005
 4949+ return $text;
 4950+ }
49494951 } else {
49504952 while ( $node ) {
49514953 if ( $node->getName() === 'h' ) {
Index: trunk/phase3/RELEASE-NOTES
@@ -197,6 +197,8 @@
198198 * (bug 28034) uploading file to local wiki when file exists on shared repository
199199 (commons) gives spurious info in the warning message
200200 * Usernames get lost when selecting different sorts on Special:listfiles
 201+* (Bug 14005) editing section 0 of an existing but empty page gives no such
 202+ section error
201203
202204 === API changes in 1.18 ===
203205 * (bug 26339) Throw warning when truncating an overlarge API result

Follow-up revisions

RevisionCommit summaryAuthorDate
r84451Reinstate some lines added during r84357...reedy15:18, 21 March 2011
r90461Expand return documentation for r84357reedy13:57, 20 June 2011
r96271Reverted r84357 and r90461 and fixed the bug in a better way: in an empty doc...tstarling06:56, 5 September 2011

Comments

#Comment by OverlordQ (talk | contribs)   14:42, 21 March 2011
Running test Section extraction test (section 0)... PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
FAILED!
--- /tmp/mwParser-870869291-expected    2011-03-21 14:40:11.000000000 +0000
+++ /tmp/mwParser-870869291-actual      2011-03-21 14:40:11.000000000 +0000
@@ -1 +1,11 @@
 start
+==a==
+===aa===
+====aaa====
+==b==
+===ba===
+===bb===
+====bba====
+===bc===
+==c==
+===ca===
Running test Section replacement test (section 0)... PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
PHP Notice:  Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980

Notice: Undefined variable: targetLevel in /var/www/thedarkcitadel.com/w/includes/parser/Parser.php on line 4980
FAILED!
--- /tmp/mwParser-1738926287-expected   2011-03-21 14:40:11.000000000 +0000
+++ /tmp/mwParser-1738926287-actual     2011-03-21 14:40:11.000000000 +0000
@@ -1,12 +1 @@
 xxx
-
-==a==
-===aa===
-====aaa====
-==b==
-===ba===
-===bb===
-====bba====
-===bc===
-==c==
-===ca===
#Comment by Aaron Schulz (talk | contribs)   22:02, 17 June 2011

From the function docs: "If the section is not found, $mode=get will return $newtext, and $mode=replace will return $text." This doesn't account for that.

#Comment by Tim Starling (talk | contribs)   06:10, 5 September 2011

Quite so. That behaviour is necessary to make section editing work at all. As it is, attempting to edit section 0 of a blank page results in the page staying blank.

Status & tagging log