jenkins-bot has submitted this change and it was merged.
Change subject: (bug 47219) Allow specifying change type of Wikipedia feed items
......................................................................
(bug 47219) Allow specifying change type of Wikipedia feed items
It exposes field /rc_type/ as ApiQueryRecentChanges does thus allowing
user to define which (edit, external, new, log) changes to show in feed.
Bug: 47219
Change-Id: If22827129b04d423711f921307dc820d4840d9d1
---
M RELEASE-NOTES-1.22
M includes/api/ApiFeedWatchlist.php
M includes/api/ApiQueryWatchlist.php
3 files changed, 85 insertions(+), 0 deletions(-)
Approvals:
Anomie: Looks good to me, approved
jenkins-bot: Verified
diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index aad11a0..ebff9d4 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -95,6 +95,7 @@
* BREAKING CHANGE: list=allpages, list=langbacklinks, and prop=langlinks do not
apply the new LanguageLinks hook, and thus only consider language links
stored in the database.
+* (bug 47219) Allow specifying change type of Wikipedia feed items
=== Languages updated in 1.22===
diff --git a/includes/api/ApiFeedWatchlist.php
b/includes/api/ApiFeedWatchlist.php
index ddcd6ac..9f6b8b4 100644
--- a/includes/api/ApiFeedWatchlist.php
+++ b/includes/api/ApiFeedWatchlist.php
@@ -91,6 +91,9 @@
if ( $params['wlshow'] !== null ) {
$fauxReqArr['wlshow'] = $params['wlshow'];
}
+ if ( $params['wltype'] !== null ) {
+ $fauxReqArr['wltype'] = $params['wltype'];
+ }
// Support linking to diffs instead of article
if ( $params['linktodiffs'] ) {
@@ -222,12 +225,14 @@
$ret['wlowner'] = $wlparams['owner'];
$ret['wltoken'] = $wlparams['token'];
$ret['wlshow'] = $wlparams['show'];
+ $ret['wltype'] = $wlparams['type'];
$ret['wlexcludeuser'] = $wlparams['excludeuser'];
} else {
$ret['allrev'] = null;
$ret['wlowner'] = null;
$ret['wltoken'] = null;
$ret['wlshow'] = null;
+ $ret['wltype'] = null;
$ret['wlexcludeuser'] = null;
}
return $ret;
@@ -244,6 +249,7 @@
'wlowner' => $wldescr['owner'],
'wltoken' => $wldescr['token'],
'wlshow' => $wldescr['show'],
+ 'wltype' => $wldescr['type'],
'wlexcludeuser' => $wldescr['excludeuser'],
);
}
diff --git a/includes/api/ApiQueryWatchlist.php
b/includes/api/ApiQueryWatchlist.php
index 3ee15f6..22843f5 100644
--- a/includes/api/ApiQueryWatchlist.php
+++ b/includes/api/ApiQueryWatchlist.php
@@ -170,6 +170,10 @@
$this->addWhereIf( 'rc_patrolled != 0', isset(
$show['patrolled'] ) );
}
+ if ( !is_null( $params['type'] ) ) {
+ $this->addWhereFld( 'rc_type', $this->parseRCType(
$params['type'] ) );
+ }
+
if ( !is_null( $params['user'] ) && !is_null(
$params['excludeuser'] ) ) {
$this->dieUsage( 'user and excludeuser cannot be used
together', 'user-excludeuser' );
}
@@ -224,6 +228,32 @@
private function extractRowInfo( $row ) {
$vals = array();
+
+ $type = intval( $row->rc_type );
+
+ /* Determine what kind of change this was. */
+ switch ( $type ) {
+ case RC_EDIT:
+ $vals['type'] = 'edit';
+ break;
+ case RC_NEW:
+ $vals['type'] = 'new';
+ break;
+ case RC_MOVE:
+ $vals['type'] = 'move';
+ break;
+ case RC_LOG:
+ $vals['type'] = 'log';
+ break;
+ case RC_EXTERNAL:
+ $vals['type'] = 'external';
+ break;
+ case RC_MOVE_OVER_REDIRECT:
+ $vals['type'] = 'move over redirect';
+ break;
+ default:
+ $vals['type'] = $type;
+ }
if ( $this->fld_ids ) {
$vals['pageid'] = intval( $row->rc_cur_id );
@@ -311,6 +341,27 @@
return $vals;
}
+ /* Copied from ApiQueryRecentChanges. */
+ private function parseRCType( $type ) {
+ if ( is_array( $type ) ) {
+ $retval = array();
+ foreach ( $type as $t ) {
+ $retval[] = $this->parseRCType( $t );
+ }
+ return $retval;
+ }
+ switch ( $type ) {
+ case 'edit':
+ return RC_EDIT;
+ case 'new':
+ return RC_NEW;
+ case 'log':
+ return RC_LOG;
+ case 'external':
+ return RC_EXTERNAL;
+ }
+ }
+
public function getAllowedParams() {
return array(
'allrev' => false,
@@ -375,6 +426,15 @@
'!patrolled',
)
),
+ 'type' => array(
+ ApiBase::PARAM_ISMULTI => true,
+ ApiBase::PARAM_TYPE => array(
+ 'edit',
+ 'external',
+ 'new',
+ 'log',
+ )
+ ),
'owner' => array(
ApiBase::PARAM_TYPE => 'user'
),
@@ -414,6 +474,13 @@
'Show only items that meet this criteria.',
"For example, to see only minor edits done by
logged-in users, set {$p}show=minor|!anon"
),
+ 'type' => array(
+ 'Which types of changes to show',
+ ' edit - Regular page edits',
+ ' external - External changes',
+ ' new - Page creations',
+ ' log - Log entries',
+ ),
'owner' => 'The name of the user whose watchlist you\'d
like to access',
'token' => 'Give a security token (settable in
preferences) to allow access to another user\'s watchlist'
);
@@ -422,6 +489,17 @@
public function getResultProperties() {
global $wgLogTypes;
return array(
+ '' => array(
+ 'type' => array(
+ ApiBase::PROP_TYPE => array(
+ 'edit',
+ 'new',
+ 'move',
+ 'log',
+ 'move over redirect'
+ )
+ )
+ ),
'ids' => array(
'pageid' => 'integer',
'revid' => 'integer',
--
To view, visit https://gerrit.wikimedia.org/r/61286
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If22827129b04d423711f921307dc820d4840d9d1
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Kaligula <[email protected]>
Gerrit-Reviewer: Aklapper <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Kaligula <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits