Use WatchedItemStore::countWatchers in SpecialWatchlist
authoraddshore <addshorewiki@gmail.com>
Mon, 14 Mar 2016 16:12:01 +0000 (16:12 +0000)
committeraddshore <addshorewiki@gmail.com>
Mon, 14 Mar 2016 16:41:18 +0000 (16:41 +0000)
Bug: T129481
Change-Id: I6da41a80bfc658106862238622f95db087c5bea7

includes/specials/SpecialWatchlist.php

index dffc9d9..7af1a54 100644 (file)
@@ -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;
                        }