From 00b3434d47ae2f99e7fed2722b69a80c42ae2e68 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sun, 10 Apr 2011 21:42:20 +0000 Subject: [PATCH] * (bug 28455) Add 'toponly' to recentchanges API module --- RELEASE-NOTES | 1 + includes/api/ApiQueryRecentChanges.php | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 22b8231fc1..fcea1f6705 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -332,6 +332,7 @@ PHP if you have not done so prior to upgrading MediaWiki. * (bug 28254) action=paraminfo: Extract type from PARAM_DFLT if PARAM_TYPE is not set * (bug 27712) add parent_id to list=deletedrevs +* (bug 28455) Add 'toponly' to recentchanges API module === Languages updated in 1.18 === diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index 76993017ac..b808185a15 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -158,8 +158,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { || ( isset( $show['anon'] ) && isset( $show['!anon'] ) ) || ( isset( $show['redirect'] ) && isset( $show['!redirect'] ) ) || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) ) - ) - { + ) { $this->dieUsageMsg( array( 'show' ) ); } @@ -213,6 +212,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { 'rc_deleted' ) ); + $showRedirects = false; /* Determine what properties we need to display. */ if ( !is_null( $params['prop'] ) ) { $prop = array_flip( $params['prop'] ); @@ -241,11 +241,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $this->addFieldsIf( 'rc_log_type', $this->fld_loginfo ); $this->addFieldsIf( 'rc_log_action', $this->fld_loginfo ); $this->addFieldsIf( 'rc_params', $this->fld_loginfo ); - if ( $this->fld_redirect || isset( $show['redirect'] ) || isset( $show['!redirect'] ) ) { - $this->addTables( 'page' ); - $this->addJoinConds( array( 'page' => array( 'LEFT JOIN', array( 'rc_namespace=page_namespace', 'rc_title=page_title' ) ) ) ); - $this->addFields( 'page_is_redirect' ); - } + $showRedirects = $this->fld_redirect || isset( $show['redirect'] ) || isset( $show['!redirect'] ); } if ( $this->fld_tags ) { @@ -254,6 +250,15 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $this->addFields( 'ts_tags' ); } + if ( $params['toponly'] || $showRedirects ) { + $this->addTables( 'page' ); + $this->addJoinConds( array( 'page' => array( 'LEFT JOIN', array( 'rc_namespace=page_namespace', 'rc_title=page_title' ) ) ) ); + + if ( $params['toponly'] ) { + $this->addWhere( 'rc_this_oldid = page_latest' ); + } + } + if ( !is_null( $params['tag'] ) ) { $this->addTables( 'change_tag' ); $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'rc_id=ct_rc_id' ) ) ) ); @@ -577,7 +582,8 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { 'new', 'log' ) - ) + ), + 'toponly' => false, ); } @@ -614,6 +620,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { 'type' => 'Which types of changes to show', 'limit' => 'How many total changes to return', 'tag' => 'Only list changes tagged with this tag', + 'toponly' => 'Only list changes which are the latest revision' ); } -- 2.20.1