From: Brad Jorsch Date: Sun, 27 Sep 2015 15:18:47 +0000 (-0400) Subject: API: Allow generator=recentchanges to generate revids X-Git-Tag: 1.31.0-rc.0~9504 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=2cf39dd2e8a42bba0d0745f62f0c213a005646f4;p=lhc%2Fweb%2Fwiklou.git API: Allow generator=recentchanges to generate revids 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 --- diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27 index 9aaa32e59e..c96eed2fde 100644 --- a/RELEASE-NOTES-1.27 +++ b/RELEASE-NOTES-1.27 @@ -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 diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index f579062983..ed0a2a7a05 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -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, ); } diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json index 64b56f02e2..5127f478ec 100644 --- a/includes/api/i18n/en.json +++ b/includes/api/i18n/en.json @@ -973,6 +973,7 @@ "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.", diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json index 0d0930db65..745aa90263 100644 --- a/includes/api/i18n/qqq.json +++ b/includes/api/i18n/qqq.json @@ -906,6 +906,7 @@ "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}}",