From: Bartosz DziewoƄski Date: Sun, 22 Dec 2013 13:24:12 +0000 (+0100) Subject: Change behavior of Special:Watchlist when user's watchlist is empty X-Git-Tag: 1.31.0-rc.0~17164^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22sites_tous%22%29%20.%20%22?a=commitdiff_plain;h=5301715a4f721754e24218573a1df3c98db7d92d;p=lhc%2Fweb%2Fwiklou.git 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 --- 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" .