74 parent::__construct( $query, $moduleName,
'pc' );
87 $pages = array_keys( $this->
getPageSet()->getGoodPages() );
90 if ( $params[
'continue'] !==
null ) {
91 $cont = explode(
'|', $params[
'continue'] );
93 $cont_page = (int)$cont[0];
94 $pages = array_filter( $pages,
static function ( $v ) use ( $cont_page ) {
95 return $v >= $cont_page;
98 if ( $pages === [] ) {
105 $continuePages =
null;
106 if ( count( $pages ) > self::MAX_PAGES ) {
108 $pages = array_slice( $pages, 0, self::MAX_PAGES );
112 $revQuery = $this->revisionStore->getQueryInfo();
113 $pageField =
'rev_page';
114 $idField =
'rev_actor';
115 $countField =
'rev_actor';
121 'page' => $pageField,
122 'anons' =>
"COUNT(DISTINCT $countField)",
125 $this->
addWhere( $this->actorMigration->isAnon(
$revQuery[
'fields'][
'rev_user'] ) );
126 $this->
addWhere( $db->bitAnd(
'rev_deleted', RevisionRecord::DELETED_USER ) .
' = 0' );
127 $this->
addOption(
'GROUP BY', $pageField );
129 foreach (
$res as $row ) {
130 $fit = $result->addValue( [
'query',
'pages', $row->page ],
131 'anoncontributors', (
int)$row->anons
138 $params[
'continue'] ??
'0|0'
150 'page' => $pageField,
153 'userid' =>
'MAX(' .
$revQuery[
'fields'][
'rev_user'] .
')',
154 'username' =>
'MAX(' .
$revQuery[
'fields'][
'rev_user_text'] .
')',
157 $this->
addWhere( $this->actorMigration->isNotAnon(
$revQuery[
'fields'][
'rev_user'] ) );
158 $this->
addWhere( $db->bitAnd(
'rev_deleted', RevisionRecord::DELETED_USER ) .
' = 0' );
159 $this->
addOption(
'GROUP BY', [ $pageField, $idField ] );
160 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
164 if ( count( $pages ) > 1 ) {
165 $this->
addOption(
'ORDER BY', [
'page',
'id' ] );
171 if ( $params[
'group'] ) {
172 $excludeGroups =
false;
173 $limitGroups = $params[
'group'];
174 } elseif ( $params[
'excludegroup'] ) {
175 $excludeGroups =
true;
176 $limitGroups = $params[
'excludegroup'];
177 } elseif ( $params[
'rights'] ) {
178 $excludeGroups =
false;
179 foreach ( $params[
'rights'] as $r ) {
180 $limitGroups = array_merge( $limitGroups,
181 $this->groupPermissionsLookup->getGroupsWithPermission( $r ) );
185 if ( !$limitGroups ) {
186 if ( $continuePages !==
null ) {
194 } elseif ( $params[
'excluderights'] ) {
195 $excludeGroups =
true;
196 foreach ( $params[
'excluderights'] as $r ) {
197 $limitGroups = array_merge( $limitGroups,
198 $this->groupPermissionsLookup->getGroupsWithPermission( $r ) );
202 if ( $limitGroups ) {
203 $limitGroups = array_unique( $limitGroups );
207 $excludeGroups ?
'LEFT JOIN' :
'JOIN',
209 'ug_user=' .
$revQuery[
'fields'][
'rev_user'],
210 'ug_group' => $limitGroups,
211 'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
216 $this->
addWhereIf(
'ug_user IS NULL', $excludeGroups );
219 if ( $params[
'continue'] !==
null ) {
220 $cont = explode(
'|', $params[
'continue'] );
222 $cont_page = (int)$cont[0];
223 $cont_id = (int)$cont[1];
225 "$pageField > $cont_page OR " .
226 "($pageField = $cont_page AND " .
227 "$idField >= $cont_id)"
233 foreach (
$res as $row ) {
234 if ( ++$count > $params[
'limit'] ) {
242 [
'userid' => (
int)$row->userid,
'name' => $row->username ],
251 if ( $continuePages !==
null ) {
261 $userGroups = $this->userGroupManager->listAllGroups();
300 'action=query&prop=contributors&titles=Main_Page'
301 =>
'apihelp-query+contributors-example-simple',
306 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Contributors';
This is not intended to be a long-term part of MediaWiki; it will be deprecated and removed once acto...
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
const LIMIT_BIG1
Fast query, standard limit.
requireMaxOneParameter( $params,... $required)
Die if more than one of a certain set of parameters is set and not false.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const GET_VALUES_FOR_HELP
getAllowedParams() flag: When set, the result could take longer to generate, but should be more thoro...
const LIMIT_BIG2
Fast query, apihighlimits limit.
This is a base class for all Query modules.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
resetQueryParams()
Blank the internal arrays with query parameters.
addWhereIf( $value, $condition)
Same as addWhere(), but add the WHERE clauses only if a condition is met.
addFields( $value)
Add a set of fields to select to the internal array.
addPageSubItem( $pageId, $item, $elemname=null)
Same as addPageSubItems(), but one element of $data at a time.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
getDB()
Get the Query database connection (read-only)
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
addWhereFld( $field, $value)
Equivalent to addWhere( [ $field => $value ] )
getPageSet()
Get the PageSet object to work on.
addWhere( $value)
Add a set of WHERE clauses to the internal array.
A query module to show contributors to a page.
GroupPermissionsLookup $groupPermissionsLookup
UserGroupManager $userGroupManager
ActorMigration $actorMigration
getExamplesMessages()
Returns usage examples for this module.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
getAllowedParams( $flags=0)
__construct(ApiQuery $query, $moduleName, RevisionStore $revisionStore, ActorMigration $actorMigration, UserGroupManager $userGroupManager, GroupPermissionsLookup $groupPermissionsLookup)
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getHelpUrls()
Return links to more detailed help pages about the module.
const MAX_PAGES
We don't want to process too many pages at once (it hits cold database pages too heavily),...
RevisionStore $revisionStore
This is the main query class.