Blackspirit96 has uploaded a new change for review. https://gerrit.wikimedia.org/r/324338
Change subject: API should allow querying user contribs by userid ...................................................................... API should allow querying user contribs by userid It verifies that the userids are valid and then it gathers all the contribs. Anonymous users are not suported by userids because every anonymous user have userid === 0. Bug: T114465 Change-Id: Id4f4fb76ea06332a7c83a55922fdfda2d665e85a --- M includes/api/ApiQueryUserContributions.php 1 file changed, 26 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/38/324338/1 diff --git a/includes/api/ApiQueryUserContributions.php b/includes/api/ApiQueryUserContributions.php index b85bec4..4084b83 100644 --- a/includes/api/ApiQueryUserContributions.php +++ b/includes/api/ApiQueryUserContributions.php @@ -70,6 +70,28 @@ $this->prefixMode = true; $this->multiUserMode = true; $this->userprefix = $this->params['userprefix']; + } else if ( isset( $this->params['userids'] ) ) { + $this->userids = []; + if ( !is_array( $this->params['userids'] ) ) { + $this->params['userids'] = [ $this->params['userids'] ]; + } + + if ( !count( $this->params['userids'] ) ) { + $this->dieUsage( 'Userids parameter may not be empty.', 'param_userids' ); + } + + foreach ($this->params['userids'] as $uid) { + if ( is_null( $uid ) || $uid === 0) { + $this->dieUsage( "Userids parameter {$uid} is not valid.", 'param_userids' ); + } + + // check for anon user is not working because anon users have userid == 0 + $this->userids[] = $uid; + } + + $this->prefixMode = false; + $this->multiUserMode = ( count( $this->params['userids'] ) > 1 ); + $this->idMode = true; } else { $anyIPs = false; $this->userids = []; @@ -489,6 +511,10 @@ ApiBase::PARAM_TYPE => 'user', ApiBase::PARAM_ISMULTI => true ], + 'userids' => [ + ApiBase::PARAM_TYPE => 'integer', + ApiBase::PARAM_ISMULTI => true + ], 'userprefix' => null, 'dir' => [ ApiBase::PARAM_DFLT => 'older', -- To view, visit https://gerrit.wikimedia.org/r/324338 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id4f4fb76ea06332a7c83a55922fdfda2d665e85a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Blackspirit96 <karata...@csd.auth.gr> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits