API: Allow generator=recentchanges to generate revids
authorBrad Jorsch <bjorsch@wikimedia.org>
Sun, 27 Sep 2015 15:18:47 +0000 (11:18 -0400)
committerKunal Mehta <legoktm@gmail.com>
Wed, 7 Oct 2015 17:07:43 +0000 (10:07 -0700)
A quick review of usage on enwiki reveals that people are currently
using generator=recentchanges with prop=revisions, so the generation of
revids is not the default to avoid breaking those clients.

Bug: T113884
Change-Id: Ia91af7099120660dc40230b76896090843985d96

RELEASE-NOTES-1.27
includes/api/ApiQueryRecentChanges.php
includes/api/i18n/en.json
includes/api/i18n/qqq.json

index 9aaa32e..c96eed2 100644 (file)
@@ -40,6 +40,7 @@ production.
 
 === Action API changes in 1.27 ===
 * Added list=allrevisions.
+* generator=recentchanges now has the option to generate revids.
 
 === Action API internal changes in 1.27 ===
 
@@ -49,10 +50,8 @@ MediaWiki supports over 350 languages. Many localisations are updated
 regularly. Below only new and removed languages are listed, as well as
 changes to languages because of Bugzilla reports.
 
-
 === Other changes in 1.27 ===
 
-
 == Compatibility ==
 
 MediaWiki 1.27 requires PHP 5.3.3 or later. There is experimental support for
index f579062..ed0a2a7 100644 (file)
@@ -297,6 +297,8 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                        $showRedirects = $this->fld_redirect || isset( $show['redirect'] )
                                || isset( $show['!redirect'] );
                }
+               $this->addFieldsIf( array( 'rc_this_oldid' ),
+                       $resultPageSet && $params['generaterevisions'] );
 
                if ( $this->fld_tags ) {
                        $this->addTables( 'tag_summary' );
@@ -366,6 +368,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                /* Perform the actual query. */
                $res = $this->select( __METHOD__ );
 
+               $revids = array();
                $titles = array();
 
                $result = $this->getResult();
@@ -389,6 +392,11 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                                        $this->setContinueEnumParameter( 'continue', "$row->rc_timestamp|$row->rc_id" );
                                        break;
                                }
+                       } elseif ( $params['generaterevisions'] ) {
+                               $revid = (int)$row->rc_this_oldid;
+                               if ( $revid > 0 ) {
+                                       $revids[] = $revid;
+                               }
                        } else {
                                $titles[] = Title::makeTitle( $row->rc_namespace, $row->rc_title );
                        }
@@ -397,6 +405,8 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                if ( is_null( $resultPageSet ) ) {
                        /* Format the result */
                        $result->addIndexedTagName( array( 'query', $this->getModuleName() ), 'rc' );
+               } elseif ( $params['generaterevisions'] ) {
+                       $resultPageSet->populateFromRevisionIDs( $revids );
                } else {
                        $resultPageSet->populateFromTitles( $titles );
                }
@@ -681,6 +691,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                        'continue' => array(
                                ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
                        ),
+                       'generaterevisions' => false,
                );
        }
 
index 64b56f0..5127f47 100644 (file)
        "apihelp-query+recentchanges-param-limit": "How many total changes to return.",
        "apihelp-query+recentchanges-param-type": "Which types of changes to show.",
        "apihelp-query+recentchanges-param-toponly": "Only list changes which are the latest revision.",
+       "apihelp-query+recentchanges-param-generaterevisions": "When being used as a generator, generate revision IDs rather than titles. Recent change entries without associated revision IDs (e.g. most log entries) will generate nothing.",
        "apihelp-query+recentchanges-example-simple": "List recent changes.",
        "apihelp-query+recentchanges-example-generator": "Get page info about recent unpatrolled changes.",
 
index 0d0930d..745aa90 100644 (file)
        "apihelp-query+recentchanges-param-limit": "{{doc-apihelp-param|query+recentchanges|limit}}",
        "apihelp-query+recentchanges-param-type": "{{doc-apihelp-param|query+recentchanges|type}}",
        "apihelp-query+recentchanges-param-toponly": "{{doc-apihelp-param|query+recentchanges|toponly}}",
+       "apihelp-query+recentchanges-param-generaterevisions": "{{doc-apihelp-param|query+recentchanges|generaterevisions}}",
        "apihelp-query+recentchanges-example-simple": "{{doc-apihelp-example|query+recentchanges}}",
        "apihelp-query+recentchanges-example-generator": "{{doc-apihelp-example|query+recentchanges}}",
        "apihelp-query+redirects-description": "{{doc-apihelp-description|query+redirects}}",