From: Aaron Schulz Date: Wed, 10 Apr 2019 21:58:31 +0000 (-0700) Subject: Merge last-seen stash data at more points in SpecialWatchlist X-Git-Tag: 1.34.0-rc.0~1919^2 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=1ef64b2f2683051066a33ba34c6d04723252c3c0;p=lhc%2Fweb%2Fwiklou.git Merge last-seen stash data at more points in SpecialWatchlist Follow-up to 7c12727fff Bug: T218511 Change-Id: I7357853f33717d6d34ca69381b0e59f67625d972 --- diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 6defc9de4f..76a331321f 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -193,11 +193,8 @@ class SpecialWatchlist extends ChangesListSpecialPage { 'cssClassSuffix' => 'watchedunseen', 'isRowApplicableCallable' => function ( $ctx, RecentChange $rc ) { $changeTs = $rc->getAttribute( 'rc_timestamp' ); - $lastVisitTs = $this->watchStore->getLatestNotificationTimestamp( - $rc->getAttribute( 'wl_notificationtimestamp' ), - $rc->getPerformer(), - $rc->getTitle() - ); + $lastVisitTs = $this->getLatestSeenTimestamp( $rc ); + return $lastVisitTs !== null && $changeTs >= $lastVisitTs; }, ], @@ -206,16 +203,26 @@ class SpecialWatchlist extends ChangesListSpecialPage { 'label' => 'rcfilters-filter-watchlistactivity-seen-label', 'description' => 'rcfilters-filter-watchlistactivity-seen-description', 'cssClassSuffix' => 'watchedseen', - 'isRowApplicableCallable' => function ( $ctx, $rc ) { + 'isRowApplicableCallable' => function ( $ctx, RecentChange $rc ) { $changeTs = $rc->getAttribute( 'rc_timestamp' ); - $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' ); + $lastVisitTs = $this->getLatestSeenTimestamp( $rc ); + return $lastVisitTs === null || $changeTs < $lastVisitTs; } ], ], 'default' => ChangesListStringOptionsFilterGroup::NONE, - 'queryCallable' => function ( $specialPageClassName, $context, $dbr, - &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) { + 'queryCallable' => function ( + $specialPageClassName, + $context, + IDatabase $dbr, + &$tables, + &$fields, + &$conds, + &$query_options, + &$join_conds, + $selectedValues + ) { if ( $selectedValues === [ 'seen' ] ) { $conds[] = $dbr->makeList( [ 'wl_notificationtimestamp IS NULL', @@ -534,7 +541,8 @@ class SpecialWatchlist extends ChangesListSpecialPage { $rc->counter = $counter++; if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) { - $updated = $obj->wl_notificationtimestamp; + $lastVisitTs = $this->getLatestSeenTimestamp( $rc ); + $updated = ( $lastVisitTs > $rc->getAttribute( 'timestamp' ) ); } else { $updated = false; } @@ -848,4 +856,16 @@ class SpecialWatchlist extends ChangesListSpecialPage { $count = $store->countWatchedItems( $this->getUser() ); return floor( $count / 2 ); } + + /** + * @param RecentChange $rc + * @return string TS_MW timestamp + */ + protected function getLatestSeenTimestamp( RecentChange $rc ) { + return $this->watchStore->getLatestNotificationTimestamp( + $rc->getAttribute( 'wl_notificationtimestamp' ), + $rc->getPerformer(), + $rc->getTitle() + ); + } }