Merge "TableDiffFormatter: Don't repeatedly call array_shift()"
[lhc/web/wiklou.git] / includes / actions / InfoAction.php
index 87d269a..f7c30b7 100644 (file)
@@ -677,39 +677,17 @@ class InfoAction extends FormlessAction {
 
                                $setOpts += Database::getCacheSetOptions( $dbr, $dbrWatchlist );
 
-                               $result = [];
+                               $watchedItemStore = WatchedItemStore::getDefaultInstance();
 
-                               // Number of page watchers
-                               $watchers = (int)$dbrWatchlist->selectField(
-                                       'watchlist',
-                                       'COUNT(*)',
-                                       [
-                                               'wl_namespace' => $title->getNamespace(),
-                                               'wl_title' => $title->getDBkey(),
-                                       ],
-                                       $fname
-                               );
-                               $result['watchers'] = $watchers;
+                               $result = [];
+                               $result['watchers'] = $watchedItemStore->countWatchers( $title );
 
                                if ( $config->get( 'ShowUpdatedMarker' ) ) {
-                                       // Threshold: last visited about 26 weeks before latest edit
                                        $updated = wfTimestamp( TS_UNIX, $page->getTimestamp() );
-                                       $age = $config->get( 'WatchersMaxAge' );
-                                       $threshold = $dbrWatchlist->timestamp( $updated - $age );
-                                       // Number of page watchers who also visited a "recent" edit
-                                       $visitingWatchers = (int)$dbrWatchlist->selectField(
-                                               'watchlist',
-                                               'COUNT(*)',
-                                               [
-                                                       'wl_namespace' => $title->getNamespace(),
-                                                       'wl_title' => $title->getDBkey(),
-                                                       'wl_notificationtimestamp >= ' .
-                                                               $dbrWatchlist->addQuotes( $threshold ) .
-                                                               ' OR wl_notificationtimestamp IS NULL'
-                                               ],
-                                               $fname
+                                       $result['visitingWatchers'] = $watchedItemStore->countVisitingWatchers(
+                                               $title,
+                                               $updated - $config->get( 'WatchersMaxAge' )
                                        );
-                                       $result['visitingWatchers'] = $visitingWatchers;
                                }
 
                                // Total number of edits
@@ -842,7 +820,7 @@ class InfoAction extends FormlessAction {
                                : $user->getUserPage();
 
                        $hiddenPrefs = $this->context->getConfig()->get( 'HiddenPrefs' );
-                       if ( $user->getID() == 0 ) {
+                       if ( $user->getId() == 0 ) {
                                $anon_ips[] = Linker::link( $page, htmlspecialchars( $user->getName() ) );
                        } elseif ( !in_array( 'realname', $hiddenPrefs ) && $user->getRealName() ) {
                                $real_names[] = Linker::link( $page, htmlspecialchars( $user->getRealName() ) );