ApiQueryWatchlist: wlshow=unread should filter revisions, not pages
authorBrad Jorsch <bjorsch@wikimedia.org>
Thu, 4 Feb 2016 14:42:57 +0000 (09:42 -0500)
committerAnomie <bjorsch@wikimedia.org>
Wed, 17 Feb 2016 15:50:35 +0000 (15:50 +0000)
It's currently showing all relevant revisions from pages with at least
one unread revision, where it would be more sensible for it to show just
the unread revisions. Something similar applies to wlshow=!unread.

Bug: T125729
Change-Id: I552901efb98081af9a1a677f4403a2a1a73bd94f

includes/api/ApiQueryWatchlist.php

index 7e561cb..db2cf86 100644 (file)
@@ -192,8 +192,11 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                        $this->addWhereIf( 'rc_user != 0', isset( $show['!anon'] ) );
                        $this->addWhereIf( 'rc_patrolled = 0', isset( $show['!patrolled'] ) );
                        $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) );
-                       $this->addWhereIf( 'wl_notificationtimestamp IS NOT NULL', isset( $show['unread'] ) );
-                       $this->addWhereIf( 'wl_notificationtimestamp IS NULL', isset( $show['!unread'] ) );
+                       $this->addWhereIf( 'rc_timestamp >= wl_notificationtimestamp', isset( $show['unread'] ) );
+                       $this->addWhereIf(
+                               'wl_notificationtimestamp IS NULL OR rc_timestamp < wl_notificationtimestamp',
+                               isset( $show['!unread'] )
+                       );
                }
 
                if ( !is_null( $params['type'] ) ) {