InfoAction: Use watchlist query group for watchlist queries
authorAlex Monk <krenair@gmail.com>
Thu, 16 Jul 2015 20:42:53 +0000 (15:42 -0500)
committerAlex Monk <krenair@gmail.com>
Thu, 16 Jul 2015 20:42:53 +0000 (15:42 -0500)
Bug: T105852
Change-Id: I8fd38caf04e60f34f76077cd66e447f09fa2f487

includes/actions/InfoAction.php

index 0c1a344..5491f81 100644 (file)
@@ -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',