35 private const MAX_PAGES = 100;
48 parent::__construct( $query, $moduleName,
'pc' );
57 $pages = array_keys( $this->
getPageSet()->getGoodPages() );
60 if ( $params[
'continue'] !==
null ) {
62 $cont_page = (int)$cont[0];
63 $pages = array_filter( $pages,
static function ( $v ) use ( $cont_page ) {
64 return $v >= $cont_page;
67 if ( $pages === [] ) {
74 $continuePages =
null;
75 if ( count( $pages ) > self::MAX_PAGES ) {
76 $continuePages = $pages[self::MAX_PAGES] .
'|0';
77 $pages = array_slice( $pages, 0, self::MAX_PAGES );
81 $revQuery = $this->revisionStore->getQueryInfo();
82 $pageField =
'rev_page';
83 $idField =
'rev_actor';
84 $countField =
'rev_actor';
91 'anons' =>
"COUNT(DISTINCT $countField)",
94 $this->
addWhere( $this->actorMigration->isAnon( $revQuery[
'fields'][
'rev_user'] ) );
95 $this->
addWhere( [ $db->bitAnd(
'rev_deleted', RevisionRecord::DELETED_USER ) => 0 ] );
96 $this->
addOption(
'GROUP BY', $pageField );
97 $res = $this->
select( __METHOD__ );
98 foreach ( $res as $row ) {
99 $fit = $result->addValue( [
'query',
'pages', $row->page ],
100 'anoncontributors', (
int)$row->anons
107 $params[
'continue'] ??
'0|0'
119 'page' => $pageField,
122 'userid' =>
'MAX(' . $revQuery[
'fields'][
'rev_user'] .
')',
123 'username' =>
'MAX(' . $revQuery[
'fields'][
'rev_user_text'] .
')',
126 $this->
addWhere( $this->actorMigration->isNotAnon( $revQuery[
'fields'][
'rev_user'] ) );
127 $this->
addWhere( [ $db->bitAnd(
'rev_deleted', RevisionRecord::DELETED_USER ) => 0 ] );
128 $this->
addOption(
'GROUP BY', [ $pageField, $idField ] );
129 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
133 if ( count( $pages ) > 1 ) {
134 $this->
addOption(
'ORDER BY', [
'page',
'id' ] );
140 if ( $params[
'group'] ) {
141 $excludeGroups =
false;
142 $limitGroups = $params[
'group'];
143 } elseif ( $params[
'excludegroup'] ) {
144 $excludeGroups =
true;
145 $limitGroups = $params[
'excludegroup'];
146 } elseif ( $params[
'rights'] ) {
147 $excludeGroups =
false;
148 foreach ( $params[
'rights'] as $r ) {
149 $limitGroups = array_merge( $limitGroups,
150 $this->groupPermissionsLookup->getGroupsWithPermission( $r ) );
154 if ( !$limitGroups ) {
155 if ( $continuePages !==
null ) {
163 } elseif ( $params[
'excluderights'] ) {
164 $excludeGroups =
true;
165 foreach ( $params[
'excluderights'] as $r ) {
166 $limitGroups = array_merge( $limitGroups,
167 $this->groupPermissionsLookup->getGroupsWithPermission( $r ) );
171 if ( $limitGroups ) {
172 $limitGroups = array_unique( $limitGroups );
176 $excludeGroups ?
'LEFT JOIN' :
'JOIN',
178 'ug_user=' . $revQuery[
'fields'][
'rev_user'],
179 'ug_group' => $limitGroups,
180 $db->expr(
'ug_expiry',
'=',
null )->or(
'ug_expiry',
'>=', $db->timestamp() )
185 $this->
addWhereIf( [
'ug_user' =>
null ], $excludeGroups );
188 if ( $params[
'continue'] !==
null ) {
190 $this->
addWhere( $db->buildComparison(
'>=', [
191 $pageField => $cont[0],
192 $idField => $cont[1],
196 $res = $this->
select( __METHOD__ );
198 foreach ( $res as $row ) {
199 if ( ++$count > $params[
'limit'] ) {
207 [
'userid' => (
int)$row->userid,
'name' => $row->username ],
216 if ( $continuePages !==
null ) {
228 $userGroups = $this->userGroupManager->listAllGroups();
237 ParamValidator::PARAM_TYPE => $userGroups,
238 ParamValidator::PARAM_ISMULTI =>
true,
241 ParamValidator::PARAM_TYPE => $userGroups,
242 ParamValidator::PARAM_ISMULTI =>
true,
245 ParamValidator::PARAM_TYPE => $userRights,
246 ParamValidator::PARAM_ISMULTI =>
true,
249 ParamValidator::PARAM_TYPE => $userRights,
250 ParamValidator::PARAM_ISMULTI =>
true,
253 ParamValidator::PARAM_DEFAULT => 10,
254 ParamValidator::PARAM_TYPE =>
'limit',
255 IntegerDef::PARAM_MIN => 1,
267 $title = Title::newMainPage()->getPrefixedText();
268 $mp = rawurlencode( $title );
271 "action=query&prop=contributors&titles={$mp}"
272 =>
'apihelp-query+contributors-example-simple',
278 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Contributors';
283 if ( $this->tempUserConfig->isKnown() ) {
284 return 'apihelp-query+contributors-summary-tempusers-enabled';
286 return parent::getSummaryMessage();
291class_alias( ApiQueryContributors::class,
'ApiQueryContributors' );