API: Add show=unread to ApiQueryWatchlist
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 3 Jun 2014 19:06:27 +0000 (15:06 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Mon, 9 Jun 2014 18:14:04 +0000 (14:14 -0400)
This allows for retrieving only those pages that have changes since the
last visit.

Bug: 65246
Change-Id: I81d2fae39178708efc0f57e5acea93b50463bc7a

RELEASE-NOTES-1.24
includes/api/ApiQueryWatchlist.php

index f0370ca..a85a3a0 100644 (file)
@@ -100,6 +100,7 @@ production.
 * action=expandtemplates has a new parameter, prop, and a new output format.
   The old format is still used if prop isn't provided, but this is deprecated.
 * meta=userinfo can now return the count of unread pages on the watchlist.
+* list=watchlist can now filter by unread status.
 
 === Languages updated in 1.24 ===
 
index 9a4dd82..837ad28 100644 (file)
@@ -168,6 +168,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                                || ( isset( $show['bot'] ) && isset( $show['!bot'] ) )
                                || ( isset( $show['anon'] ) && isset( $show['!anon'] ) )
                                || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
+                               || ( isset( $show['unread'] ) && isset( $show['!unread'] ) )
                        ) {
                                $this->dieUsageMsg( 'show' );
                        }
@@ -191,6 +192,8 @@ 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'] ) );
                }
 
                if ( !is_null( $params['type'] ) ) {
@@ -490,6 +493,8 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                                        '!anon',
                                        'patrolled',
                                        '!patrolled',
+                                       'unread',
+                                       '!unread',
                                )
                        ),
                        'type' => array(