From: umherirrender Date: Sun, 13 Jan 2013 19:21:27 +0000 (+0100) Subject: Pass database connection to SpecialWatchlist::countItems X-Git-Tag: 1.31.0-rc.0~20970^2 X-Git-Url: http://git.cyclocoop.org/%24dirpuce/puce%24spip_lang_rtl.gif?a=commitdiff_plain;h=00da4a9a07134dc580b97f3009951be93ff638f7;p=lhc%2Fweb%2Fwiklou.git Pass database connection to SpecialWatchlist::countItems This avoids getting two connection to the 'watchlist' group. Change-Id: I36cefc7d54cb6ed6c58a6f16932809b72a573d98 --- 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__ );