Last modified: 2011-10-12 01:16:47 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 4834 - setting $wgMaxTocLevel can cause invalid xhtml output (extra </ul> and <li> tags)
setting $wgMaxTocLevel can cause invalid xhtml output (extra </ul> and <li> t...
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
PC Linux
: Normal minor (vote)
: ---
Assigned To: Nobody - You can work on this!
Depends on:
  Show dependency treegraph
Reported: 2006-02-02 09:19 UTC by Ramana Kumar
Modified: 2011-10-12 01:16 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description Ramana Kumar 2006-02-02 09:19:04 UTC
Parser.php calls $sk->tocIndent() and $sk->tocUnindent( $prevtoclevel -
$toclevel ) even if the heading in question is above the $wgMaxTocLevel.

The default for $wgMaxTocLevel is 999, so usually this problem doesn't surface.
But if it is set to something low like 2 or 3, and there are headings on the
page which are greater than this level, the resulting page has an invalid list
in the table of contents. (There are extra <ul> </ul> <li> and </li> tags and
the nesting makes no sense. It doesn't validate as valid xhtml 1.0 transitional.)

I believe a simple fix can be accomplished by adding "if( (
!isset($wgMaxTocLevel) || $toclevel<$wgMaxTocLevel ) )" before "$toc .=
$sk->tocIndent();" and "if( ( !isset($wgMaxTocLevel) ||
$prevtoclevel<$wgMaxTocLevel ) )" before "$toc .= $sk->tocUnindent(
$prevtoclevel - $toclevel );" in Parser.php. This ensures that the tocIndent and
tocUnindent functions are only called if the heading is actually going to appear
in the toc. (these lines only appear once in Parser.php so they should be easy
to find and easy to fix.)
Comment 1 Ramana Kumar 2006-02-02 09:28:44 UTC
I missed a further complication.
The unindent bit should actually end up like this:

if ( ( !isset($wgMaxTocLevel) || $prevtoclevel<$wgMaxTocLevel ) ) {
	$toc .= $sk->tocUnindent( $prevtoclevel - $toclevel );
elseif ( ( !isset($wgMaxTocLevel) || $toclevel<$wgMaxTocLevel ) ) {
	$toc .= $sk->tocUnindent( 0 );

otherwise list elements for headings which are above unshown headings will not
be closed.
Comment 2 Brion Vibber 2006-02-02 17:30:29 UTC
Why does this setting even exist? It seems a bit silly.
Comment 3 Ramana Kumar 2006-02-02 21:47:40 UTC
It's being put to good use on my wiki. No wait - I'll explain further: I wanted
to create sections without headings (like this: "== ==") so that I could put
"[edit]" links (and horizontal rules etc.) down the page without having to
explicitly give names for the sections. But then I didn't want these sections to
show up in the TOC. That's why I'm using $wgMaxTocLevel. If there were a
different way to add an [edit] link without adding a section, I wouldn't have to
use $wgMaxTocLevel. I might have a look at the code some time (if anybody's
interested) to see how easy that would be to accomplish... (I'm not motivated
now though since my sections with spaces for titles work fine...)
Comment 4 Antoine "hashar" Musso (WMF) 2006-04-25 19:48:47 UTC
Fixed in trunk@13867
Fixed in REL1_6@13868

Would be in MediaWiki 1.6.4

Note You need to log in before you can comment on or make changes to this bug.