* (bug 13922) Fix bad HTML on empty Special:Prefixindex and Special:Allpages
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 1 May 2008 22:07:24 +0000 (22:07 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 1 May 2008 22:07:24 +0000 (22:07 +0000)
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
includes/SpecialAllpages.php
includes/SpecialPrefixindex.php

index 7b8b730..4ec765e 100644 (file)
@@ -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 ===
index 2c3d74e..9748a6b 100644 (file)
@@ -257,30 +257,34 @@ function showChunk( $namespace = NS_MAIN, $from, $including = false ) {
                        )
                );
 
-               $out = '<table style="background: inherit;" border="0" width="100%">';
-
-               while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
-                       $t = Title::makeTitle( $s->page_namespace, $s->page_title );
-                       if( $t ) {
-                               $link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
-                                       $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) .
-                                       ($s->page_is_redirect ? '</div>' : '' );
-                       } else {
-                               $link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
-                       }
-                       if( $n % 3 == 0 ) {
-                               $out .= '<tr>';
+               if( $res->numRows() > 0 ) {
+                       $out = '<table style="background: inherit;" border="0" width="100%">';
+       
+                       while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
+                               $t = Title::makeTitle( $s->page_namespace, $s->page_title );
+                               if( $t ) {
+                                       $link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
+                                               $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) .
+                                               ($s->page_is_redirect ? '</div>' : '' );
+                               } else {
+                                       $link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
+                               }
+                               if( $n % 3 == 0 ) {
+                                       $out .= '<tr>';
+                               }
+                               $out .= "<td width=\"33%\">$link</td>";
+                               $n++;
+                               if( $n % 3 == 0 ) {
+                                       $out .= '</tr>';
+                               }
                        }
-                       $out .= "<td width=\"33%\">$link</td>";
-                       $n++;
-                       if( $n % 3 == 0 ) {
+                       if( ($n % 3) != 0 ) {
                                $out .= '</tr>';
                        }
+                       $out .= '</table>';
+               } else {
+                       $out = '';
                }
-               if( ($n % 3) != 0 ) {
-                       $out .= '</tr>';
-               }
-               $out .= '</table>';
        }
 
        if ( $including ) {
index 63d9eb1..092f81c 100644 (file)
@@ -96,30 +96,34 @@ class SpecialPrefixindex extends SpecialAllpages {
                        ### FIXME: side link to previous
 
                        $n = 0;
-                       $out = '<table style="background: inherit;" border="0" width="100%">';
-
-                       while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
-                               $t = Title::makeTitle( $s->page_namespace, $s->page_title );
-                               if( $t ) {
-                                       $link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
-                                               $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) .
-                                               ($s->page_is_redirect ? '</div>' : '' );
-                               } else {
-                                       $link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
+                       if( $res->numRows() > 0 ) {
+                               $out = '<table style="background: inherit;" border="0" width="100%">';
+       
+                               while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
+                                       $t = Title::makeTitle( $s->page_namespace, $s->page_title );
+                                       if( $t ) {
+                                               $link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
+                                                       $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) .
+                                                       ($s->page_is_redirect ? '</div>' : '' );
+                                       } else {
+                                               $link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
+                                       }
+                                       if( $n % 3 == 0 ) {
+                                               $out .= '<tr>';
+                                       }
+                                       $out .= "<td>$link</td>";
+                                       $n++;
+                                       if( $n % 3 == 0 ) {
+                                               $out .= '</tr>';
+                                       }
                                }
-                               if( $n % 3 == 0 ) {
-                                       $out .= '<tr>';
-                               }
-                               $out .= "<td>$link</td>";
-                               $n++;
-                               if( $n % 3 == 0 ) {
+                               if( ($n % 3) != 0 ) {
                                        $out .= '</tr>';
                                }
+                               $out .= '</table>';
+                       } else {
+                               $out = '';
                        }
-                       if( ($n % 3) != 0 ) {
-                               $out .= '</tr>';
-                       }
-                       $out .= '</table>';
                }
 
                if ( $including ) {