49 private const MAX_PAGES = 100;
68 parent::__construct( $query, $moduleName,
'pc' );
69 $this->revisionStore = $revisionStore;
70 $this->actorMigration = $actorMigration;
71 $this->userGroupManager = $userGroupManager;
72 $this->groupPermissionsLookup = $groupPermissionsLookup;
73 $this->tempUserConfig = $tempUserConfig;
82 $pages = array_keys( $this->
getPageSet()->getGoodPages() );
85 if (
$params[
'continue'] !==
null ) {
87 $cont_page = (int)$cont[0];
88 $pages = array_filter( $pages,
static function ( $v ) use ( $cont_page ) {
89 return $v >= $cont_page;
92 if ( $pages === [] ) {
99 $continuePages =
null;
100 if ( count( $pages ) > self::MAX_PAGES ) {
101 $continuePages = $pages[self::MAX_PAGES] .
'|0';
102 $pages = array_slice( $pages, 0, self::MAX_PAGES );
106 $revQuery = $this->revisionStore->getQueryInfo();
107 $pageField =
'rev_page';
108 $idField =
'rev_actor';
109 $countField =
'rev_actor';
115 'page' => $pageField,
116 'anons' =>
"COUNT(DISTINCT $countField)",
119 $this->
addWhere( $this->actorMigration->isAnon( $revQuery[
'fields'][
'rev_user'] ) );
120 $this->
addWhere( [ $db->bitAnd(
'rev_deleted', RevisionRecord::DELETED_USER ) => 0 ] );
121 $this->
addOption(
'GROUP BY', $pageField );
122 $res = $this->
select( __METHOD__ );
123 foreach ( $res as $row ) {
124 $fit = $result->addValue( [
'query',
'pages', $row->page ],
125 'anoncontributors', (
int)$row->anons
144 'page' => $pageField,
147 'userid' =>
'MAX(' . $revQuery[
'fields'][
'rev_user'] .
')',
148 'username' =>
'MAX(' . $revQuery[
'fields'][
'rev_user_text'] .
')',
151 $this->
addWhere( $this->actorMigration->isNotAnon( $revQuery[
'fields'][
'rev_user'] ) );
152 $this->
addWhere( [ $db->bitAnd(
'rev_deleted', RevisionRecord::DELETED_USER ) => 0 ] );
153 $this->
addOption(
'GROUP BY', [ $pageField, $idField ] );
158 if ( count( $pages ) > 1 ) {
159 $this->
addOption(
'ORDER BY', [
'page',
'id' ] );
166 $excludeGroups =
false;
167 $limitGroups =
$params[
'group'];
168 } elseif (
$params[
'excludegroup'] ) {
169 $excludeGroups =
true;
170 $limitGroups =
$params[
'excludegroup'];
171 } elseif (
$params[
'rights'] ) {
172 $excludeGroups =
false;
173 foreach (
$params[
'rights'] as $r ) {
174 $limitGroups = array_merge( $limitGroups,
175 $this->groupPermissionsLookup->getGroupsWithPermission( $r ) );
179 if ( !$limitGroups ) {
180 if ( $continuePages !==
null ) {
188 } elseif (
$params[
'excluderights'] ) {
189 $excludeGroups =
true;
190 foreach (
$params[
'excluderights'] as $r ) {
191 $limitGroups = array_merge( $limitGroups,
192 $this->groupPermissionsLookup->getGroupsWithPermission( $r ) );
196 if ( $limitGroups ) {
197 $limitGroups = array_unique( $limitGroups );
201 $excludeGroups ?
'LEFT JOIN' :
'JOIN',
203 'ug_user=' . $revQuery[
'fields'][
'rev_user'],
204 'ug_group' => $limitGroups,
205 $db->expr(
'ug_expiry',
'=',
null )->or(
'ug_expiry',
'>=', $db->timestamp() )
210 $this->
addWhereIf( [
'ug_user' =>
null ], $excludeGroups );
213 if (
$params[
'continue'] !==
null ) {
215 $this->
addWhere( $db->buildComparison(
'>=', [
216 $pageField => $cont[0],
217 $idField => $cont[1],
221 $res = $this->
select( __METHOD__ );
223 foreach ( $res as $row ) {
224 if ( ++$count >
$params[
'limit'] ) {
232 [
'userid' => (
int)$row->userid,
'name' => $row->username ],
241 if ( $continuePages !==
null ) {
251 $userGroups = $this->userGroupManager->listAllGroups();
260 ParamValidator::PARAM_TYPE => $userGroups,
261 ParamValidator::PARAM_ISMULTI =>
true,
264 ParamValidator::PARAM_TYPE => $userGroups,
265 ParamValidator::PARAM_ISMULTI =>
true,
268 ParamValidator::PARAM_TYPE => $userRights,
269 ParamValidator::PARAM_ISMULTI =>
true,
272 ParamValidator::PARAM_TYPE => $userRights,
273 ParamValidator::PARAM_ISMULTI =>
true,
276 ParamValidator::PARAM_DEFAULT => 10,
277 ParamValidator::PARAM_TYPE =>
'limit',
278 IntegerDef::PARAM_MIN => 1,
289 $title = Title::newMainPage()->getPrefixedText();
290 $mp = rawurlencode( $title );
293 "action=query&prop=contributors&titles={$mp}"
294 =>
'apihelp-query+contributors-example-simple',
299 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Contributors';
303 if ( $this->tempUserConfig->isKnown() ) {
304 return 'apihelp-query+contributors-summary-tempusers-enabled';
306 return parent::getSummaryMessage();
311class_alias( ApiQueryContributors::class,
'ApiQueryContributors' );
array $params
The job parameters.