From a2e0bf21864912f22350fc0bb5d67e896f53b6e6 Mon Sep 17 00:00:00 2001 From: Alex Monk Date: Thu, 16 Jul 2015 15:42:53 -0500 Subject: [PATCH] InfoAction: Use watchlist query group for watchlist queries Bug: T105852 Change-Id: I8fd38caf04e60f34f76077cd66e447f09fa2f487 --- includes/actions/InfoAction.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index 0c1a344864..5491f817b4 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -675,11 +675,11 @@ class InfoAction extends FormlessAction { $id = $title->getArticleID(); $config = $this->context->getConfig(); - $dbr = wfGetDB( DB_SLAVE ); + $dbrWatchlist = wfGetDB( DB_SLAVE, 'watchlist' ); $result = array(); // Number of page watchers - $watchers = (int)$dbr->selectField( + $watchers = (int)$dbrWatchlist->selectField( 'watchlist', 'COUNT(*)', array( @@ -694,15 +694,15 @@ class InfoAction extends FormlessAction { // Threshold: last visited about 26 weeks before latest edit $updated = wfTimestamp( TS_UNIX, $this->page->getTimestamp() ); $age = $config->get( 'WatchersMaxAge' ); - $threshold = $dbr->timestamp( $updated - $age ); + $threshold = $dbrWatchlist->timestamp( $updated - $age ); // Number of page watchers who also visited a "recent" edit - $visitingWatchers = (int)$dbr->selectField( + $visitingWatchers = (int)$dbrWatchlist->selectField( 'watchlist', 'COUNT(*)', array( 'wl_namespace' => $title->getNamespace(), 'wl_title' => $title->getDBkey(), - 'wl_notificationtimestamp >= ' . $dbr->addQuotes( $threshold ) . + 'wl_notificationtimestamp >= ' . $dbrWatchlist->addQuotes( $threshold ) . ' OR wl_notificationtimestamp IS NULL' ), __METHOD__ @@ -710,6 +710,7 @@ class InfoAction extends FormlessAction { $result['visitingWatchers'] = $visitingWatchers; } + $dbr = wfGetDB( DB_SLAVE ); // Total number of edits $edits = (int)$dbr->selectField( 'revision', -- 2.20.1