+
+ $this->watchers = MediaWikiServices::getInstance()->getWatchedItemStore()->countWatchersMultiple(
+ $this->everything,
+ $countOptions
+ );
+ }
+
+ /**
+ * Get the count of watchers who have visited recent edits and put it in
+ * $this->visitingwatchers
+ *
+ * Based on InfoAction::pageCounts
+ */
+ private function getVisitingWatcherInfo() {
+ $config = $this->getConfig();
+ $user = $this->getUser();
+ $db = $this->getDB();
+
+ $canUnwatchedpages = $user->isAllowed( 'unwatchedpages' );
+ $unwatchedPageThreshold = $this->getConfig()->get( 'UnwatchedPageThreshold' );
+ if ( !$canUnwatchedpages && !is_int( $unwatchedPageThreshold ) ) {
+ return;
+ }
+
+ $this->showZeroWatchers = $canUnwatchedpages;
+
+ $titlesWithThresholds = [];
+ if ( $this->titles ) {
+ $lb = new LinkBatch( $this->titles );
+
+ // Fetch last edit timestamps for pages
+ $this->resetQueryParams();
+ $this->addTables( [ 'page', 'revision' ] );
+ $this->addFields( [ 'page_namespace', 'page_title', 'rev_timestamp' ] );
+ $this->addWhere( [
+ 'page_latest = rev_id',
+ $lb->constructSet( 'page', $db ),
+ ] );
+ $this->addOption( 'GROUP BY', [ 'page_namespace', 'page_title' ] );
+ $timestampRes = $this->select( __METHOD__ );
+
+ $age = $config->get( 'WatchersMaxAge' );
+ $timestamps = [];
+ foreach ( $timestampRes as $row ) {
+ $revTimestamp = wfTimestamp( TS_UNIX, (int)$row->rev_timestamp );
+ $timestamps[$row->page_namespace][$row->page_title] = $revTimestamp - $age;
+ }
+ $titlesWithThresholds = array_map(
+ function ( LinkTarget $target ) use ( $timestamps ) {
+ return [
+ $target, $timestamps[$target->getNamespace()][$target->getDBkey()]
+ ];
+ },
+ $this->titles
+ );
+ }
+
+ if ( $this->missing ) {
+ $titlesWithThresholds = array_merge(
+ $titlesWithThresholds,
+ array_map(
+ function ( LinkTarget $target ) {
+ return [ $target, null ];
+ },
+ $this->missing
+ )
+ );
+ }
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+ $this->visitingwatchers = $store->countVisitingWatchersMultiple(
+ $titlesWithThresholds,
+ !$canUnwatchedpages ? $unwatchedPageThreshold : null
+ );