* (bug 28455) Add 'toponly' to recentchanges API module
authorSam Reed <reedy@users.mediawiki.org>
Sun, 10 Apr 2011 21:42:20 +0000 (21:42 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sun, 10 Apr 2011 21:42:20 +0000 (21:42 +0000)
RELEASE-NOTES
includes/api/ApiQueryRecentChanges.php

index 22b8231..fcea1f6 100644 (file)
@@ -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 ===
 
index 7699301..b808185 100644 (file)
@@ -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'
                );
        }