(bug 19017) TOC level calculation error in an odd case. Patch by Brad Jorsch.
authorSiebrand Mazeland <siebrand@users.mediawiki.org>
Mon, 1 Jun 2009 16:39:18 +0000 (16:39 +0000)
committerSiebrand Mazeland <siebrand@users.mediawiki.org>
Mon, 1 Jun 2009 16:39:18 +0000 (16:39 +0000)
RELEASE-NOTES
includes/parser/Parser.php

index 509f4ec..400c511 100644 (file)
@@ -180,6 +180,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   variable instead of using this to overrules the user language preference.
 * (bug 19014) If user had deletedhistory right, but not undeleted right, then 
   show "view" instead of "view/restore" on logs.
+* (bug 19017) TOC level calculation error in an odd case
 
 == API changes in 1.16 ==
 
index f17cf0a..27f55f7 100644 (file)
@@ -3477,23 +3477,19 @@ class Parser
                                elseif ( $level < $prevlevel && $toclevel > 1 ) {
                                        # Decrease TOC level, find level to jump to
 
-                                       if ( $toclevel == 2 && $level <= $levelCount[1] ) {
-                                               # Can only go down to level 1
-                                               $toclevel = 1;
-                                       } else {
-                                               for ($i = $toclevel; $i > 0; $i--) {
-                                                       if ( $levelCount[$i] == $level ) {
-                                                               # Found last matching level
-                                                               $toclevel = $i;
-                                                               break;
-                                                       }
-                                                       elseif ( $levelCount[$i] < $level ) {
-                                                               # Found first matching level below current level
-                                                               $toclevel = $i + 1;
-                                                               break;
-                                                       }
+                                       for ($i = $toclevel; $i > 0; $i--) {
+                                               if ( $levelCount[$i] == $level ) {
+                                                       # Found last matching level
+                                                       $toclevel = $i;
+                                                       break;
+                                               }
+                                               elseif ( $levelCount[$i] < $level ) {
+                                                       # Found first matching level below current level
+                                                       $toclevel = $i + 1;
+                                                       break;
                                                }
                                        }
+                                       if( $i == 0 ) $toclevel = 1;
                                        if( $toclevel<$wgMaxTocLevel ) {
                                                if($prevtoclevel < $wgMaxTocLevel) {
                                                        # Unindent only if the previous toc level was shown :p