From 65904ba1bb82e246914e1f5efdcf00f89adba9a3 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Fri, 25 Oct 2013 12:11:08 +0200 Subject: [PATCH] Add show=unpatrolled to the recentchanges API Adding it only in the API because SpecialRecentChanges only shows "Hide patrolled edits" option if rcpatrol is enabled. show=!patrolled returns results that include changes that can't be patrolled which technically correct (they aren't correct) but probably not what you're looking for when looking for unpatrolled changes. Change-Id: I356a8625c7126b90aa7e7a23efe3bef7d448b502 --- includes/api/ApiQueryRecentChanges.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index 7848853048..50a335233d 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -192,12 +192,14 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { || ( isset( $show['anon'] ) && isset( $show['!anon'] ) ) || ( isset( $show['redirect'] ) && isset( $show['!redirect'] ) ) || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) ) + || ( isset( $show['patrolled'] ) && isset( $show['unpatrolled'] ) ) + || ( isset( $show['!patrolled'] ) && isset( $show['unpatrolled'] ) ) ) { $this->dieUsageMsg( 'show' ); } // Check permissions - if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) { + if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) || isset( $show['unpatrolled'] ) ) { if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) { $this->dieUsage( 'You need the patrol right to request the patrolled flag', @@ -217,6 +219,16 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) ); $this->addWhereIf( 'page_is_redirect = 1', isset( $show['redirect'] ) ); + if ( isset( $show['unpatrolled'] ) ) { + // See ChangesList:isUnpatrolled + if ( $user->useRCPatrol() ) { + $this->addWhere( 'rc_patrolled = 0' ); + } elseif ( $user->useNPPatrol() ) { + $this->addWhere( 'rc_patrolled = 0' ); + $this->addWhereFld( 'rc_type', RC_NEW ); + } + } + // Don't throw log entries out the window here $this->addWhereIf( 'page_is_redirect = 0 OR page_is_redirect IS NULL', @@ -639,7 +651,8 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { 'redirect', '!redirect', 'patrolled', - '!patrolled' + '!patrolled', + 'unpatrolled' ) ), 'limit' => array( -- 2.20.1