From 00da4a9a07134dc580b97f3009951be93ff638f7 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sun, 13 Jan 2013 20:21:27 +0100 Subject: [PATCH] Pass database connection to SpecialWatchlist::countItems This avoids getting two connection to the 'watchlist' group. Change-Id: I36cefc7d54cb6ed6c58a6f16932809b72a573d98 --- includes/specials/SpecialWatchlist.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 3cfa31f167..029cc29d26 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -91,7 +91,9 @@ class SpecialWatchlist extends SpecialPage { return; } - $nitems = $this->countItems(); + $dbr = wfGetDB( DB_SLAVE, 'watchlist' ); + + $nitems = $this->countItems( $dbr ); if ( $nitems == 0 ) { $output->addWikiMsg( 'nowatchlist' ); return; @@ -190,8 +192,6 @@ class SpecialWatchlist extends SpecialPage { return; } - $dbr = wfGetDB( DB_SLAVE, 'watchlist' ); - # Possible where conditions $conds = array(); @@ -497,11 +497,10 @@ class SpecialWatchlist extends SpecialPage { /** * Count the number of items on a user's watchlist * + * @param $dbr A database connection * @return Integer */ - protected function countItems() { - $dbr = wfGetDB( DB_SLAVE, 'watchlist' ); - + protected function countItems( $dbr ) { # Fetch the raw count $res = $dbr->select( 'watchlist', array( 'count' => 'COUNT(*)' ), array( 'wl_user' => $this->getUser()->getId() ), __METHOD__ ); -- 2.20.1