}
if ( $this->fld_watchers ) {
- if ( isset( $this->watchers[$ns][$dbkey] ) ) {
+ if ( $this->watchers[$ns][$dbkey] !== 0 || $this->showZeroWatchers ) {
$pageInfo['watchers'] = $this->watchers[$ns][$dbkey];
- } elseif ( $this->showZeroWatchers ) {
- $pageInfo['watchers'] = 0;
}
}
return;
}
- $this->watchers = [];
$this->showZeroWatchers = $canUnwatchedpages;
- $db = $this->getDB();
-
- $lb = new LinkBatch( $this->everything );
- $this->resetQueryParams();
- $this->addTables( [ 'watchlist' ] );
- $this->addFields( [ 'wl_title', 'wl_namespace', 'count' => 'COUNT(*)' ] );
- $this->addWhere( [
- $lb->constructSet( 'wl', $db )
- ] );
- $this->addOption( 'GROUP BY', [ 'wl_namespace', 'wl_title' ] );
+ $countOptions = [];
if ( !$canUnwatchedpages ) {
- $this->addOption( 'HAVING', "COUNT(*) >= $unwatchedPageThreshold" );
+ $countOptions['minimumWatchers'] = $unwatchedPageThreshold;
}
- $res = $this->select( __METHOD__ );
-
- foreach ( $res as $row ) {
- $this->watchers[$row->wl_namespace][$row->wl_title] = (int)$row->count;
- }
+ $this->watchers = WatchedItemStore::getDefaultInstance()->countWatchersMultiple(
+ $this->everything,
+ $countOptions
+ );
}
/**