$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
: $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() ) );