From 5301715a4f721754e24218573a1df3c98db7d92d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Sun, 22 Dec 2013 14:24:12 +0100 Subject: [PATCH] Change behavior of Special:Watchlist when user's watchlist is empty Previously it would display nothing but a message saying that "You have no items on your watchlist.", not even any information about what we are looking at or a link to edit watchlist's contents. Now the full view is displayed, with the old message placed instead of "N pages on your watchlist, not counting talk pages." at the top. Change-Id: Ice9be8bb0686c3c20712d814f08a5171380bf45d --- includes/specials/SpecialWatchlist.php | 31 +++++++++++++------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index fc4842190c..c664e311fa 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -71,14 +71,6 @@ class SpecialWatchlist extends ChangesListSpecialPage { $this->outputHeader(); $this->addModules(); - $dbr = wfGetDB( DB_SLAVE, 'watchlist' ); - - $this->numItems = $this->countItems( $dbr ); // TODO kill me - if ( $this->numItems == 0 ) { - $output->addWikiMsg( 'nowatchlist' ); - return; - } - // Fetch results, prepare a batch link existence check query $conds = $this->buildMainQueryConds( $opts ); $rows = $this->doMainQuery( $conds, $opts ); @@ -516,18 +508,25 @@ class SpecialWatchlist extends ChangesListSpecialPage { $form = ""; $user = $this->getUser(); - # Show watchlist header + $dbr = wfGetDB( DB_SLAVE, 'watchlist' ); + $numItems = $this->countItems( $dbr ); + + // Show watchlist header $form .= "

"; - $form .= $this->msg( 'watchlist-details' )->numParams( $this->numItems )->parse() . "\n"; - if ( $wgEnotifWatchlist && $user->getOption( 'enotifwatchlistpages' ) ) { - $form .= $this->msg( 'wlheader-enotif' )->parse() . "\n"; - } - if ( $wgShowUpdatedMarker ) { - $form .= $this->msg( 'wlheader-showupdated' )->parse() . "\n"; + if ( $numItems == 0 ) { + $form .= $this->msg( 'nowatchlist' )->parse() . "\n"; + } else { + $form .= $this->msg( 'watchlist-details' )->numParams( $numItems )->parse() . "\n"; + if ( $wgEnotifWatchlist && $user->getOption( 'enotifwatchlistpages' ) ) { + $form .= $this->msg( 'wlheader-enotif' )->parse() . "\n"; + } + if ( $wgShowUpdatedMarker ) { + $form .= $this->msg( 'wlheader-showupdated' )->parse() . "\n"; + } } $form .= "

"; - if ( $wgShowUpdatedMarker ) { + if ( $numItems > 0 && $wgShowUpdatedMarker ) { $form .= Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getPageTitle()->getLocalURL(), 'id' => 'mw-watchlist-resetbutton' ) ) . "\n" . -- 2.20.1