Special:Watchlist: Don't try to render empty row
[lhc/web/wiklou.git] / includes / specials / SpecialWatchlist.php
index 1add311..9c28d06 100644 (file)
@@ -87,7 +87,8 @@ class SpecialWatchlist extends ChangesListSpecialPage {
         * @return string[] Matching subpages
         */
        public function prefixSearchSubpages( $search, $limit = 10 ) {
-               $subpages = array( 'edit', 'raw' );
+               // See also SpecialEditWatchlist::prefixSearchSubpages
+               $subpages = array( 'clear', 'edit', 'raw' );
                $escaped = preg_quote( $search );
                return array_slice( preg_grep( "/^$escaped/i", $subpages ), 0, $limit );
        }
@@ -330,6 +331,14 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        $output->showLagWarning( $lag );
                }
 
+               # If no rows to display, show message before try to render the list
+               if ( $rows->numRows() == 0 ) {
+                       $output->wrapWikiMsg(
+                               "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
+                       );
+                       return;
+               }
+
                $dbr->dataSeek( $rows, 0 );
 
                $list = ChangesList::newFromContext( $this->getContext() );
@@ -369,13 +378,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                }
                $s .= $list->endRecentChangesList();
 
-               if ( $rows->numRows() == 0 ) {
-                       $output->wrapWikiMsg(
-                               "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
-                       );
-               } else {
-                       $output->addHTML( $s );
-               }
+               $output->addHTML( $s );
        }
 
        /**