From 40da2bd661e5017d91d48cababaa36e44b1e56a7 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 1 May 2008 22:07:24 +0000 Subject: [PATCH] * (bug 13922) Fix bad HTML on empty Special:Prefixindex and Special:Allpages Ugh! Somebody please clean up this duplicated code.... allpages and prefixindex have lots of duplicated bits. I swear one used to be a subclass of the other, did they get copied? Or did I do that years ago and forget? :D --- RELEASE-NOTES | 1 + includes/SpecialAllpages.php | 44 ++++++++++++++++++--------------- includes/SpecialPrefixindex.php | 44 ++++++++++++++++++--------------- 3 files changed, 49 insertions(+), 40 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7b8b7305e6..4ec765e8dc 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -234,6 +234,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 13915) Undefined variable $wltsfield in includes/SpecialWatchlist.php * (bug 13913) Special:Whatlinkshere now has correct HTML markup * (bug 13905) Blacklist Mac IE from HttpOnly cookies; it eats them sometimes +* (bug 13922) Fix bad HTML on empty Special:Prefixindex and Special:Allpages === API changes in 1.13 === diff --git a/includes/SpecialAllpages.php b/includes/SpecialAllpages.php index 2c3d74e777..9748a6bce1 100644 --- a/includes/SpecialAllpages.php +++ b/includes/SpecialAllpages.php @@ -257,30 +257,34 @@ function showChunk( $namespace = NS_MAIN, $from, $including = false ) { ) ); - $out = ''; - - while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) { - $t = Title::makeTitle( $s->page_namespace, $s->page_title ); - if( $t ) { - $link = ($s->page_is_redirect ? '
' : '' ) . - $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) . - ($s->page_is_redirect ? '
' : '' ); - } else { - $link = '[[' . htmlspecialchars( $s->page_title ) . ']]'; - } - if( $n % 3 == 0 ) { - $out .= ''; + if( $res->numRows() > 0 ) { + $out = '
'; + + while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) { + $t = Title::makeTitle( $s->page_namespace, $s->page_title ); + if( $t ) { + $link = ($s->page_is_redirect ? '
' : '' ) . + $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) . + ($s->page_is_redirect ? '
' : '' ); + } else { + $link = '[[' . htmlspecialchars( $s->page_title ) . ']]'; + } + if( $n % 3 == 0 ) { + $out .= ''; + } + $out .= ""; + $n++; + if( $n % 3 == 0 ) { + $out .= ''; + } } - $out .= ""; - $n++; - if( $n % 3 == 0 ) { + if( ($n % 3) != 0 ) { $out .= ''; } + $out .= '
$link
$link
'; + } else { + $out = ''; } - if( ($n % 3) != 0 ) { - $out .= ''; - } - $out .= ''; } if ( $including ) { diff --git a/includes/SpecialPrefixindex.php b/includes/SpecialPrefixindex.php index 63d9eb1e54..092f81c4fe 100644 --- a/includes/SpecialPrefixindex.php +++ b/includes/SpecialPrefixindex.php @@ -96,30 +96,34 @@ class SpecialPrefixindex extends SpecialAllpages { ### FIXME: side link to previous $n = 0; - $out = ''; - - while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) { - $t = Title::makeTitle( $s->page_namespace, $s->page_title ); - if( $t ) { - $link = ($s->page_is_redirect ? '
' : '' ) . - $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) . - ($s->page_is_redirect ? '
' : '' ); - } else { - $link = '[[' . htmlspecialchars( $s->page_title ) . ']]'; + if( $res->numRows() > 0 ) { + $out = '
'; + + while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) { + $t = Title::makeTitle( $s->page_namespace, $s->page_title ); + if( $t ) { + $link = ($s->page_is_redirect ? '
' : '' ) . + $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) . + ($s->page_is_redirect ? '
' : '' ); + } else { + $link = '[[' . htmlspecialchars( $s->page_title ) . ']]'; + } + if( $n % 3 == 0 ) { + $out .= ''; + } + $out .= ""; + $n++; + if( $n % 3 == 0 ) { + $out .= ''; + } } - if( $n % 3 == 0 ) { - $out .= ''; - } - $out .= ""; - $n++; - if( $n % 3 == 0 ) { + if( ($n % 3) != 0 ) { $out .= ''; } + $out .= '
$link
$link
'; + } else { + $out = ''; } - if( ($n % 3) != 0 ) { - $out .= ''; - } - $out .= ''; } if ( $including ) { -- 2.20.1