From 4d0da3a3c3ad656f64e25e5e2995624bb62b3fab Mon Sep 17 00:00:00 2001 From: addshore Date: Mon, 14 Mar 2016 16:12:01 +0000 Subject: [PATCH] Use WatchedItemStore::countWatchers in SpecialWatchlist Bug: T129481 Change-Id: I6da41a80bfc658106862238622f95db087c5bea7 --- includes/specials/SpecialWatchlist.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index dffc9d9885..7af1a54f0a 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -362,6 +362,12 @@ class SpecialWatchlist extends ChangesListSpecialPage { $list->initChangesListRows( $rows ); $dbr->dataSeek( $rows, 0 ); + if ( $this->getConfig()->get( 'RCShowWatchingUsers' ) + && $user->getOption( 'shownumberswatching' ) + ) { + $watchedItemStore = WatchedItemStore::getDefaultInstance(); + } + $s = $list->beginRecentChangesList(); $counter = 1; foreach ( $rows as $obj ) { @@ -375,16 +381,9 @@ class SpecialWatchlist extends ChangesListSpecialPage { $updated = false; } - if ( $this->getConfig()->get( 'RCShowWatchingUsers' ) - && $user->getOption( 'shownumberswatching' ) - ) { - $rc->numberofWatchingusers = $dbr->selectField( 'watchlist', - 'COUNT(*)', - [ - 'wl_namespace' => $obj->rc_namespace, - 'wl_title' => $obj->rc_title, - ], - __METHOD__ ); + if ( isset( $watchedItemStore ) ) { + $rcTitleValue = new TitleValue( $obj->rc_namespace, $obj->rc_title ); + $rc->numberofWatchingusers = $watchedItemStore->countWatchers( $rcTitleValue ); } else { $rc->numberofWatchingusers = 0; } -- 2.20.1