$output = $this->getOutput();
$request = $this->getRequest();
$this->addHelpLink( 'Help:Watching pages' );
- $output->addModules( array(
+ $output->addModules( [
'mediawiki.special.changeslist.visitedstatus',
- ) );
+ ] );
$mode = SpecialEditWatchlist::getMode( $request, $subpage );
if ( $mode !== false ) {
* @return string[] subpages
*/
public function getSubpagesForPrefixSearch() {
- return array(
+ return [
'clear',
'edit',
'raw',
- );
+ ];
}
/**
protected function getCustomFilters() {
if ( $this->customFilters === null ) {
$this->customFilters = parent::getCustomFilters();
- Hooks::run( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ), '1.23' );
+ Hooks::run( 'SpecialWatchlistFilters', [ $this, &$this->customFilters ], '1.23' );
}
return $this->customFilters;
* @return FormOptions
*/
protected function fetchOptionsFromRequest( $opts ) {
- static $compatibilityMap = array(
+ static $compatibilityMap = [
'hideMinor' => 'hideminor',
'hideBots' => 'hidebots',
'hideAnons' => 'hideanons',
'hideLiu' => 'hideliu',
'hidePatrolled' => 'hidepatrolled',
'hideOwn' => 'hidemyself',
- );
+ ];
$params = $this->getRequest()->getValues();
foreach ( $compatibilityMap as $from => $to ) {
$usePage = false;
} else {
# Top log Ids for a page are not stored
- $nonRevisionTypes = array( RC_LOG );
- Hooks::run( 'SpecialWatchlistGetNonRevisionTypes', array( &$nonRevisionTypes ) );
+ $nonRevisionTypes = [ RC_LOG ];
+ Hooks::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] );
if ( $nonRevisionTypes ) {
$conds[] = $dbr->makeList(
- array(
+ [
'rc_this_oldid=page_latest',
'rc_type' => $nonRevisionTypes,
- ),
+ ],
LIST_OR
);
}
$usePage = true;
}
- $tables = array( 'recentchanges', 'watchlist' );
+ $tables = [ 'recentchanges', 'watchlist' ];
$fields = RecentChange::selectFields();
- $query_options = array( 'ORDER BY' => 'rc_timestamp DESC' );
- $join_conds = array(
- 'watchlist' => array(
+ $query_options = [ 'ORDER BY' => 'rc_timestamp DESC' ];
+ $join_conds = [
+ 'watchlist' => [
'INNER JOIN',
- array(
+ [
'wl_user' => $user->getId(),
'wl_namespace=rc_namespace',
'wl_title=rc_title'
- ),
- ),
- );
+ ],
+ ],
+ ];
if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
$fields[] = 'wl_notificationtimestamp';
$rollbacker = $user->isAllowed( 'rollback' );
if ( $usePage || $rollbacker ) {
$tables[] = 'page';
- $join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' );
+ $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
if ( $rollbacker ) {
$fields[] = 'page_latest';
}
$bitmask = 0;
}
if ( $bitmask ) {
- $conds[] = $dbr->makeList( array(
+ $conds[] = $dbr->makeList( [
'rc_type != ' . RC_LOG,
$dbr->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
- ), LIST_OR );
+ ], LIST_OR );
}
ChangeTags::modifyDisplayQuery(
return parent::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
&& Hooks::run(
'SpecialWatchlistQuery',
- array( &$conds, &$tables, &$join_conds, &$fields, $opts ),
+ [ &$conds, &$tables, &$join_conds, &$fields, $opts ],
'1.23'
);
}
$user = $this->getUser();
$wlToken = $user->getTokenFromOption( 'watchlisttoken' );
if ( $wlToken ) {
- $this->addFeedLinks( array(
+ $this->addFeedLinks( [
'action' => 'feedwatchlist',
'allrev' => 1,
'wlowner' => $user->getName(),
'wltoken' => $wlToken,
- ) );
+ ] );
}
}
$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(*)',
- array(
- '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;
}
// if the user wishes, that the watchlist is reloaded, whenever a filter changes,
// add the module for that
if ( $user->getBoolOption( 'watchlistreloadautomatically' ) ) {
- $out->addModules( array( 'mediawiki.special.watchlist' ) );
+ $out->addModules( [ 'mediawiki.special.watchlist' ] );
}
$out->addSubtitle(
$cutofflinks = $this->msg( 'wlshowtime' ) . ' ' . $this->cutoffselector( $opts );
# Spit out some control panel links
- $filters = array(
+ $filters = [
'hideminor' => 'wlshowhideminor',
'hidebots' => 'wlshowhidebots',
'hideanons' => 'wlshowhideanons',
'hideliu' => 'wlshowhideliu',
'hidemyself' => 'wlshowhidemine',
'hidepatrolled' => 'wlshowhidepatr'
- );
+ ];
if ( $this->getConfig()->get( 'RCWatchCategoryMembership' ) ) {
$filters['hidecategorization'] = 'wlshowhidecategorization';
unset( $filters['hidepatrolled'] );
}
- $links = array();
+ $links = [];
foreach ( $filters as $name => $msg ) {
$links[] = $this->showHideCheck( $nondefaults, $msg, $name, $opts[$name] );
}
implode( ' ', $links );
$form .= "\n<br />\n";
$form .= Html::namespaceSelector(
- array(
+ [
'selected' => $opts['namespace'],
'all' => '',
'label' => $this->msg( 'namespace' )->text()
- ), array(
+ ], [
'name' => 'namespace',
'id' => 'namespace',
'class' => 'namespaceselector',
- )
+ ]
) . "\n";
$form .= '<span class="mw-input-with-label">' . Xml::checkLabel(
$this->msg( 'invert' )->text(),
'invert',
'nsinvert',
$opts['invert'],
- array( 'title' => $this->msg( 'tooltip-invert' )->text() )
+ [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
) . "</span>\n";
$form .= '<span class="mw-input-with-label">' . Xml::checkLabel(
$this->msg( 'namespace_association' )->text(),
'associated',
'nsassociated',
$opts['associated'],
- array( 'title' => $this->msg( 'tooltip-namespace_association' )->text() )
+ [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
) . "</span>\n";
$form .= Xml::submitButton( $this->msg( 'watchlist-submit' )->text() ) . "\n";
foreach ( $hiddenFields as $key => $value ) {
// default string representation, for example, and would confuse comparisons.
// Misleadingly, the 'days' option supports hours too.
- $days = array_map( 'strval', array( 1/24, 2/24, 6/24, 12/24, 1, 3, 7 ) );
+ $days = array_map( 'strval', [ 1/24, 2/24, 6/24, 12/24, 1, 3, 7 ] );
$userWatchlistOption = (string)$this->getUser()->getOption( 'watchlistdays' );
// add the user preference, if it isn't available already
$form = "";
$user = $this->getUser();
- $dbr = $this->getDB();
- $numItems = $this->countItems( $dbr );
+ $numItems = $this->countItems();
$showUpdatedMarker = $this->getConfig()->get( 'ShowUpdatedMarker' );
// Show watchlist header
$form .= "</p>";
if ( $numItems > 0 && $showUpdatedMarker ) {
- $form .= Xml::openElement( 'form', array( 'method' => 'post',
+ $form .= Xml::openElement( 'form', [ 'method' => 'post',
'action' => $this->getPageTitle()->getLocalURL(),
- 'id' => 'mw-watchlist-resetbutton' ) ) . "\n" .
- Xml::submitButton( $this->msg( 'enotif_reset' )->text(), array( 'name' => 'dummy' ) ) . "\n" .
+ 'id' => 'mw-watchlist-resetbutton' ] ) . "\n" .
+ Xml::submitButton( $this->msg( 'enotif_reset' )->text(), [ 'name' => 'dummy' ] ) . "\n" .
Html::hidden( 'reset', 'all' ) . "\n";
foreach ( $nondefaults as $key => $value ) {
$form .= Html::hidden( $key, $value ) . "\n";
$form .= Xml::closeElement( 'form' ) . "\n";
}
- $form .= Xml::openElement( 'form', array(
+ $form .= Xml::openElement( 'form', [
'method' => 'get',
'action' => $this->getPageTitle()->getLocalURL(),
'id' => 'mw-watchlist-form'
- ) );
+ ] );
$form .= Xml::fieldset(
$this->msg( 'watchlist-options' )->text(),
false,
- array( 'id' => 'mw-watchlist-options' )
+ [ 'id' => 'mw-watchlist-options' ]
);
$form .= $this->makeLegend();
}
/**
- * 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', array( 'count' => 'COUNT(*)' ),
- array( '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 );
}
}