}
}
- public static function checkStructuredFilterUiEnabled( Config $config, User $user ) {
+ /**
+ * @see ChangesListSpecialPage::checkStructuredFilterUiEnabled
+ */
+ public static function checkStructuredFilterUiEnabled( $user ) {
+ if ( $user instanceof Config ) {
+ wfDeprecated( __METHOD__ . ' with Config argument', '1.34' );
+ $user = func_get_arg( 1 );
+ }
return !$user->getOption( 'wlenhancedfilters-disable' );
}
/**
* @inheritDoc
+ * @suppress PhanUndeclaredMethod
*/
protected function registerFilters() {
parent::registerFilters();
'description' => 'rcfilters-filter-watchlistactivity-unseen-description',
'cssClassSuffix' => 'watchedunseen',
'isRowApplicableCallable' => function ( $ctx, RecentChange $rc ) {
- $changeTs = $rc->getAttribute( 'rc_timestamp' );
- $lastVisitTs = $this->getLatestSeenTimestamp( $rc );
-
- return $lastVisitTs !== null && $changeTs >= $lastVisitTs;
+ return !$this->isChangeEffectivelySeen( $rc );
},
],
[
'description' => 'rcfilters-filter-watchlistactivity-seen-description',
'cssClassSuffix' => 'watchedseen',
'isRowApplicableCallable' => function ( $ctx, RecentChange $rc ) {
- $changeTs = $rc->getAttribute( 'rc_timestamp' );
- $lastVisitTs = $this->getLatestSeenTimestamp( $rc );
-
- return $lastVisitTs === null || $changeTs < $lastVisitTs;
+ return $this->isChangeEffectivelySeen( $rc );
}
],
],
// Log entries with DELETED_ACTION must not show up unless the user has
// the necessary rights.
- if ( !$user->isAllowed( 'deletedhistory' ) ) {
+ $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
+ if ( !$permissionManager->userHasRight( $user, 'deletedhistory' ) ) {
$bitmask = LogPage::DELETED_ACTION;
- } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
+ } elseif ( !$permissionManager->userHasAnyRight( $user, 'suppressrevision', 'viewsuppressed' ) ) {
$bitmask = LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED;
} else {
$bitmask = 0;
$rc->counter = $counter++;
if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
- $lastVisitTs = $this->getLatestSeenTimestamp( $rc );
- $updated = ( $lastVisitTs > $rc->getAttribute( 'timestamp' ) );
+ $unseen = !$this->isChangeEffectivelySeen( $rc );
} else {
- $updated = false;
+ $unseen = false;
}
if ( isset( $watchedItemStore ) ) {
$rc->numberofWatchingusers = 0;
}
- $changeLine = $list->recentChangesLine( $rc, $updated, $counter );
+ // XXX: this treats pages with no unseen changes as "not on the watchlist" since
+ // everything is on the watchlist and it is an easy way to make pages with unseen
+ // changes appear bold. @TODO: clean this up.
+ $changeLine = $list->recentChangesLine( $rc, $unseen, $counter );
if ( $changeLine !== false ) {
$s .= $changeLine;
}
/**
* @param RecentChange $rc
- * @return string TS_MW timestamp
+ * @return bool User viewed the revision or a newer one
+ */
+ protected function isChangeEffectivelySeen( RecentChange $rc ) {
+ $firstUnseen = $this->getLatestNotificationTimestamp( $rc );
+
+ return ( $firstUnseen === null || $firstUnseen > $rc->getAttribute( 'rc_timestamp' ) );
+ }
+
+ /**
+ * @param RecentChange $rc
+ * @return string|null TS_MW timestamp of first unseen revision or null if there isn't one
*/
- protected function getLatestSeenTimestamp( RecentChange $rc ) {
+ private function getLatestNotificationTimestamp( RecentChange $rc ) {
return $this->watchStore->getLatestNotificationTimestamp(
$rc->getAttribute( 'wl_notificationtimestamp' ),
- $rc->getPerformer(),
+ $this->getUser(),
$rc->getTitle()
);
}