From: Stephane Bisson Date: Fri, 25 Aug 2017 12:59:26 +0000 (-0400) Subject: WLFilters: Fix seen/unseen filters X-Git-Tag: 1.31.0-rc.0~2297^2 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=aeae96ef951509df9a5298b8cf910f9cac520bb6;hp=-c;p=lhc%2Fweb%2Fwiklou.git WLFilters: Fix seen/unseen filters Handle the fact that wl_notificationtimestamp can be null. Always join with 'page' table to support highlight. Bug: T171127 Change-Id: I150a41b131d64163e06bfa56bddbd762bb636655 --- aeae96ef951509df9a5298b8cf910f9cac520bb6 diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index b20b33117b..a17f118c1c 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -157,7 +157,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { 'isRowApplicableCallable' => function ( $ctx, $rc ) { $changeTs = $rc->getAttribute( 'rc_timestamp' ); $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' ); - return $changeTs >= $lastVisitTs; + return $lastVisitTs !== null && $changeTs >= $lastVisitTs; }, ], [ @@ -168,7 +168,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { 'isRowApplicableCallable' => function ( $ctx, $rc ) { $changeTs = $rc->getAttribute( 'rc_timestamp' ); $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' ); - return $changeTs < $lastVisitTs; + return $lastVisitTs === null || $changeTs < $lastVisitTs; } ], ], @@ -176,9 +176,15 @@ class SpecialWatchlist extends ChangesListSpecialPage { 'queryCallable' => function ( $specialPageClassName, $context, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) { if ( $selectedValues === [ 'seen' ] ) { - $conds[] = 'rc_timestamp < wl_notificationtimestamp'; + $conds[] = $dbr->makeList( [ + 'wl_notificationtimestamp IS NULL', + 'rc_timestamp < wl_notificationtimestamp' + ], LIST_OR ); } elseif ( $selectedValues === [ 'unseen' ] ) { - $conds[] = 'rc_timestamp >= wl_notificationtimestamp'; + $conds[] = $dbr->makeList( [ + 'wl_notificationtimestamp IS NOT NULL', + 'rc_timestamp >= wl_notificationtimestamp' + ], LIST_AND ); } } ] ) ); @@ -336,9 +342,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { $user = $this->getUser(); # Toggle watchlist content (all recent edits or just the latest) - if ( $opts['extended'] ) { - $usePage = false; - } else { + if ( !$opts['extended'] ) { # Top log Ids for a page are not stored $nonRevisionTypes = [ RC_LOG ]; Hooks::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] ); @@ -351,7 +355,6 @@ class SpecialWatchlist extends ChangesListSpecialPage { LIST_OR ); } - $usePage = true; } $tables = array_merge( [ 'recentchanges', 'watchlist' ], $tables ); @@ -375,18 +378,11 @@ class SpecialWatchlist extends ChangesListSpecialPage { $join_conds ); - if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) { - $fields[] = 'wl_notificationtimestamp'; - } + $tables[] = 'page'; + $fields[] = 'page_latest'; + $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ]; - $rollbacker = $user->isAllowed( 'rollback' ); - if ( $usePage || $rollbacker ) { - $tables[] = 'page'; - $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ]; - if ( $rollbacker ) { - $fields[] = 'page_latest'; - } - } + $fields[] = 'wl_notificationtimestamp'; // Log entries with DELETED_ACTION must not show up unless the user has // the necessary rights.