$list->initChangesListRows( $rows );
$dbr->dataSeek( $rows, 0 );
+ if ( $this->getConfig()->get( 'RCShowWatchingUsers' )
+ && $user->getOption( 'shownumberswatching' )
+ ) {
+ $watchedItemStore = WatchedItemStore::getDefaultInstance();
+ }
+
$s = $list->beginRecentChangesList();
+ $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
$counter = 1;
foreach ( $rows as $obj ) {
# Make RC entry
$rc = RecentChange::newFromRow( $obj );
+
+ # Skip CatWatch entries for hidden cats based on user preference
+ if (
+ $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE &&
+ !$userShowHiddenCats &&
+ $rc->getParam( 'hidden-cat' )
+ ) {
+ continue;
+ }
+
$rc->counter = $counter++;
if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
$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( (int)$obj->rc_namespace, $obj->rc_title );
+ $rc->numberofWatchingusers = $watchedItemStore->countWatchers( $rcTitleValue );
} else {
$rc->numberofWatchingusers = 0;
}
$form = "";
$user = $this->getUser();
- $dbr = $this->getDB();
- $numItems = $this->countItems( $dbr );
+ $numItems = $this->countItems();
$showUpdatedMarker = $this->getConfig()->get( 'ShowUpdatedMarker' );
// Show watchlist header
}
/**
- * Count the number of items on a user's watchlist
+ * Count the number of paired items on a user's watchlist.
+ * The assumption made here is that when a subject page is watched a talk page is also watched.
+ * Hence the number of individual items is halved.
*
- * @param IDatabase $dbr A database connection
* @return int
*/
- protected function countItems( $dbr ) {
- # Fetch the raw count
- $rows = $dbr->select( 'watchlist', [ 'count' => 'COUNT(*)' ],
- [ 'wl_user' => $this->getUser()->getId() ], __METHOD__ );
- $row = $dbr->fetchObject( $rows );
- $count = $row->count;
-
+ protected function countItems() {
+ $count = WatchedItemStore::getDefaultInstance()->countWatchedItems( $this->getUser() );
return floor( $count / 2 );
}
}