Merge "WLFilters: Fix seen/unseen filters"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 25 Aug 2017 19:56:52 +0000 (19:56 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 25 Aug 2017 19:56:52 +0000 (19:56 +0000)
1  2 
includes/specials/SpecialWatchlist.php

@@@ -157,7 -157,7 +157,7 @@@ class SpecialWatchlist extends ChangesL
                                        'isRowApplicableCallable' => function ( $ctx, $rc ) {
                                                $changeTs = $rc->getAttribute( 'rc_timestamp' );
                                                $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
-                                               return $changeTs >= $lastVisitTs;
+                                               return $lastVisitTs !== null && $changeTs >= $lastVisitTs;
                                        },
                                ],
                                [
                                        'isRowApplicableCallable' => function ( $ctx, $rc ) {
                                                $changeTs = $rc->getAttribute( 'rc_timestamp' );
                                                $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
-                                               return $changeTs < $lastVisitTs;
+                                               return $lastVisitTs === null || $changeTs < $lastVisitTs;
                                        }
                                ],
                        ],
                        '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 );
                                }
                        }
                ] ) );
                $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 ] );
                                        LIST_OR
                                );
                        }
-                       $usePage = true;
                }
  
                $tables = array_merge( [ 'recentchanges', 'watchlist' ], $tables );
                        $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.
  
                $this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts );
  
 +              if ( $this->areFiltersInConflict() ) {
 +                      return false;
 +              }
 +
                return $dbr->select(
                        $tables,
                        $fields,