r21829 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21828‎ | r21829 | r21830 >
Date:17:14, 3 May 2007
Author:brion
Status:old
Tags:
Comment:
Revert r21725 (bug 6204) due to regressions (bug 9764). Will leave it to be worked out on trunk for next version.
Merged parser test case for the regression from r21810
Modified paths:
  • /branches/REL1_10/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_10/phase3/includes/Parser.php (modified) (history)
  • /branches/REL1_10/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: branches/REL1_10/phase3/maintenance/parserTests.txt
@@ -3370,6 +3370,44 @@
33713371 !! end
33723372
33733373 !! test
 3374+TOC regression (bug 9764)
 3375+!! input
 3376+== title 1 ==
 3377+=== title 1.1 ===
 3378+==== title 1.1.1 ====
 3379+=== title 1.2 ===
 3380+== title 2 ==
 3381+=== title 2.1 ===
 3382+!! result
 3383+<table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
 3384+<ul>
 3385+<li class="toclevel-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
 3386+<ul>
 3387+<li class="toclevel-2"><a href="#title_1.1"><span class="tocnumber">1.1</span> <span class="toctext">title 1.1</span></a>
 3388+<ul>
 3389+<li class="toclevel-3"><a href="#title_1.1.1"><span class="tocnumber">1.1.1</span> <span class="toctext">title 1.1.1</span></a></li>
 3390+</ul>
 3391+</li>
 3392+<li class="toclevel-2"><a href="#title_1.2"><span class="tocnumber">1.2</span> <span class="toctext">title 1.2</span></a></li>
 3393+</ul>
 3394+</li>
 3395+<li class="toclevel-1"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
 3396+<ul>
 3397+<li class="toclevel-2"><a href="#title_2.1"><span class="tocnumber">2.1</span> <span class="toctext">title 2.1</span></a></li>
 3398+</ul>
 3399+</li>
 3400+</ul>
 3401+</td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
 3402+<a name="title_1"></a><h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: title 1">edit</a>]</span> <span class="mw-headline"> title 1 </span></h2>
 3403+<a name="title_1.1"></a><h3><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: title 1.1">edit</a>]</span> <span class="mw-headline"> title 1.1 </span></h3>
 3404+<a name="title_1.1.1"></a><h4><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: title 1.1.1">edit</a>]</span> <span class="mw-headline"> title 1.1.1 </span></h4>
 3405+<a name="title_1.2"></a><h3><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: title 1.2">edit</a>]</span> <span class="mw-headline"> title 1.2 </span></h3>
 3406+<a name="title_2"></a><h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: title 2">edit</a>]</span> <span class="mw-headline"> title 2 </span></h2>
 3407+<a name="title_2.1"></a><h3><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: title 2.1">edit</a>]</span> <span class="mw-headline"> title 2.1 </span></h3>
 3408+
 3409+!! end
 3410+
 3411+!! test
33743412 Resolving duplicate section names
33753413 !! input
33763414 == Foo bar ==
Index: branches/REL1_10/phase3/includes/Parser.php
@@ -3453,13 +3453,17 @@
34543454 $enoughToc = true;
34553455 }
34563456
 3457+ # Never ever show TOC if no headers
 3458+ if( $numMatches < 1 ) {
 3459+ $enoughToc = false;
 3460+ }
 3461+
34573462 # We need this to perform operations on the HTML
34583463 $sk = $this->mOptions->getSkin();
34593464
34603465 # headline counter
34613466 $headlineCount = 0;
34623467 $sectionCount = 0; # headlineCount excluding template sections
3463 - $numVisible = 0;
34643468
34653469 # Ugh .. the TOC should have neat indentation levels which can be
34663470 # passed to the skin functions. These are determined here
@@ -3489,6 +3493,7 @@
34903494
34913495 if( $toclevel ) {
34923496 $prevlevel = $level;
 3497+ $prevtoclevel = $toclevel;
34933498 }
34943499 $level = $matches[1][$headlineCount];
34953500
@@ -3499,9 +3504,7 @@
35003505 $toclevel++;
35013506 $sublevelCount[$toclevel] = 0;
35023507 if( $toclevel<$wgMaxTocLevel ) {
3503 - $prevtoclevel = $toclevel;
35043508 $toc .= $sk->tocIndent();
3505 - $numVisible++;
35063509 }
35073510 }
35083511 elseif ( $level < $prevlevel && $toclevel > 1 ) {
@@ -3608,14 +3611,9 @@
36093612 $sectionCount++;
36103613 }
36113614
3612 - # Never ever show TOC if no headers
3613 - if( $numVisible < 1 ) {
3614 - $enoughToc = false;
3615 - }
3616 -
36173615 if( $enoughToc ) {
3618 - if( $prevtoclevel > 0 && $prevtoclevel < $wgMaxTocLevel ) {
3619 - $toc .= $sk->tocUnindent( $prevtoclevel - 1 );
 3616+ if( $toclevel<$wgMaxTocLevel ) {
 3617+ $toc .= $sk->tocUnindent( $toclevel - 1 );
36203618 }
36213619 $toc = $sk->tocList( $toc );
36223620 }
Index: branches/REL1_10/phase3/RELEASE-NOTES
@@ -377,10 +377,6 @@
378378 * (bug 8602) Converted Special:Contributions to use an IndexPager. The
379379 interpretation of the offset parameter has changed, and the go parameter
380380 has been removed.
381 -* (bug 6204) Fixes for indentation with $wgMaxTocLevel:
382 - - don't emit too many list close tags after an invisible header
383 - - don't emit too many final list close tags if last header is invisible
384 - - don't emit TOC when there are no visible headers
385381 * (bug 7629) Fix $wgBrowserBlackList to avoid false positive on MSIE
386382 when certain plugins are present which alter the user agent
387383

Follow-up revisions

RevisionCommit summaryAuthorDate
r21833Parser test for bug #6204 : TOC not properly rendered when using $wgMaxTocLevelhashar17:49, 3 May 2007
r25291Revert r25260; breaks several parser tests cases, seems to be borking up sect...brion16:01, 29 August 2007
r25303Merged revisions 25215-25302 via svnmerge from...david07:10, 30 August 2007
r38208Revert r38196, r38204 -- "(bugs 6089, 13079) Show edit section links for tran...brion23:56, 29 July 2008
r53308Fix parser tests for r52213....catrope11:29, 15 July 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r21725* (bug 6204) Fixes for indentation with $wgMaxTocLevel:...brion19:51, 30 April 2007
r21810Add parser test for regression bug 9764brion18:45, 2 May 2007