From: Siebrand Mazeland Date: Mon, 1 Jun 2009 16:39:18 +0000 (+0000) Subject: (bug 19017) TOC level calculation error in an odd case. Patch by Brad Jorsch. X-Git-Tag: 1.31.0-rc.0~41559 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=0d23260d8130a6ba2e453a9ee5d80519dddffb87;p=lhc%2Fweb%2Fwiklou.git (bug 19017) TOC level calculation error in an odd case. Patch by Brad Jorsch. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 509f4ec555..400c511b2e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index f17cf0ad02..27f55f7d98 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -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