From: jenkins-bot Date: Mon, 6 May 2019 19:59:46 +0000 (+0000) Subject: Merge "Consolidate duplicated unseen change logic and fix inconsistent code" X-Git-Tag: 1.34.0-rc.0~1790 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=57609f4ded4c9ac529d7fbfd30d3585372fcc0ce;hp=5f3b124dfefcd7d0da0ebfd89f9ac2dbcc5fdba3;p=lhc%2Fweb%2Fwiklou.git Merge "Consolidate duplicated unseen change logic and fix inconsistent code" --- diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index bac059d2ae..812f1b00ab 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -199,10 +199,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { '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 ); }, ], [ @@ -211,10 +208,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { '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 ); } ], ], @@ -548,10 +542,9 @@ class SpecialWatchlist extends ChangesListSpecialPage { $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 ) ) { @@ -561,7 +554,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { $rc->numberofWatchingusers = 0; } - $changeLine = $list->recentChangesLine( $rc, $updated, $counter ); + $changeLine = $list->recentChangesLine( $rc, $unseen, $counter ); if ( $changeLine !== false ) { $s .= $changeLine; } @@ -869,9 +862,19 @@ class SpecialWatchlist extends ChangesListSpecialPage { /** * @param RecentChange $rc - * @return string TS_MW timestamp + * @return bool User viewed the revision or a newer one + */ + protected function isChangeEffectivelySeen( RecentChange $rc ) { + $lastVisitTs = $this->getLatestSeenTimestampIfHasUnseen( $rc ); + + return $lastVisitTs === null || $lastVisitTs > $rc->getAttribute( 'rc_timestamp' ); + } + + /** + * @param RecentChange $rc + * @return string|null TS_MW timestamp or null if all revision were seen */ - protected function getLatestSeenTimestamp( RecentChange $rc ) { + private function getLatestSeenTimestampIfHasUnseen( RecentChange $rc ) { return $this->watchStore->getLatestNotificationTimestamp( $rc->getAttribute( 'wl_notificationtimestamp' ), $rc->getPerformer(), diff --git a/includes/watcheditem/WatchedItemStoreInterface.php b/includes/watcheditem/WatchedItemStoreInterface.php index 54c02d7bca..5ff29d0d5d 100644 --- a/includes/watcheditem/WatchedItemStoreInterface.php +++ b/includes/watcheditem/WatchedItemStoreInterface.php @@ -341,7 +341,7 @@ interface WatchedItemStoreInterface { * @param string|null $timestamp Value of wl_notificationtimestamp from the DB * @param UserIdentity $user * @param LinkTarget $target - * @return string TS_MW timestamp or null + * @return string|null TS_MW timestamp or null if all revision were seen */ public function getLatestNotificationTimestamp( $timestamp, UserIdentity $user, LinkTarget $target );