diff options
-rw-r--r-- | includes/specials/SpecialAllPages.php | 10 | ||||
-rw-r--r-- | includes/specials/SpecialPrefixindex.php | 12 | ||||
-rw-r--r-- | tests/parser/parserTests.txt | 12 |
3 files changed, 21 insertions, 13 deletions
diff --git a/includes/specials/SpecialAllPages.php b/includes/specials/SpecialAllPages.php index 244627008577..190fe8f739b2 100644 --- a/includes/specials/SpecialAllPages.php +++ b/includes/specials/SpecialAllPages.php @@ -205,8 +205,7 @@ class SpecialAllPages extends IncludableSpecialPage { ); if ( $res->numRows() > 0 ) { - $out = Html::openElement( 'div', array( 'class' => 'mw-allpages-body' ) ); - $out .= Html::openElement( 'ul', array( 'class' => 'mw-allpages-chunk' ) ); + $out = Html::openElement( 'ul', array( 'class' => 'mw-allpages-chunk' ) ); while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { $t = Title::newFromRow( $s ); @@ -222,7 +221,12 @@ class SpecialAllPages extends IncludableSpecialPage { $n++; } $out .= Html::closeElement( 'ul' ); - $out .= Html::closeElement( 'div' ); + + if ( $res->numRows() > 2 ) { + // Only apply CSS column styles if there's more than 2 entries. + // Otherwise, rendering is broken as "mw-allpages-body"'s CSS column count is 3. + $out = Html::rawElement( 'div', array( 'class' => 'mw-allpages-body' ), $out ); + } } else { $out = ''; } diff --git a/includes/specials/SpecialPrefixindex.php b/includes/specials/SpecialPrefixindex.php index fbe5ab39eafc..f10a979922d1 100644 --- a/includes/specials/SpecialPrefixindex.php +++ b/includes/specials/SpecialPrefixindex.php @@ -205,8 +205,7 @@ class SpecialPrefixindex extends SpecialAllPages { $n = 0; if ( $res->numRows() > 0 ) { - $out = Html::openElement( 'div', array( 'class' => 'mw-prefixindex-body' ) ); - $out .= Html::openElement( 'ul', array( 'class' => 'mw-prefixindex-list' ) ); + $out = Html::openElement( 'ul', array( 'class' => 'mw-prefixindex-list' ) ); $prefixLength = strlen( $prefix ); while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { @@ -228,12 +227,17 @@ class SpecialPrefixindex extends SpecialAllPages { $link = '[[' . htmlspecialchars( $s->page_title ) . ']]'; } - $out .= "<li> $link </li>\n"; + $out .= "<li>$link</li>\n"; $n++; } $out .= Html::closeElement( 'ul' ); - $out .= Html::closeElement( 'div' ); + + if ( $res->numRows() > 2 ) { + // Only apply CSS column styles if there's more than 2 entries. + // Otherwise rendering is broken as "mw-prefixindex-body"'s CSS column count is 3. + $out = Html::rawElement( 'div', array( 'class' => 'mw-prefixindex-body' ), $out ); + } } else { $out = ''; } diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 4e6c5916952a..c127be270503 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -17173,8 +17173,8 @@ Special page transclusion !! wikitext {{Special:Prefixindex/Xyzzyx}} !! html -<div class="mw-prefixindex-body"><ul class="mw-prefixindex-list"><li> <a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a> </li> -</ul></div> +<ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li> +</ul> !! end @@ -17185,10 +17185,10 @@ Special page transclusion twice (bug 5021) {{Special:Prefixindex/Xyzzyx}} {{Special:Prefixindex/Xyzzyx}} !! html -<div class="mw-prefixindex-body"><ul class="mw-prefixindex-list"><li> <a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a> </li> -</ul></div> -<div class="mw-prefixindex-body"><ul class="mw-prefixindex-list"><li> <a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a> </li> -</ul></div> +<ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li> +</ul> +<ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li> +</ul> !! end |