74 parent::__construct( $query, $moduleName,
'pc' );
89 $pages = array_keys( $this->
getPageSet()->getGoodTitles() );
92 if ( $params[
'continue'] !==
null ) {
93 $cont = explode(
'|', $params[
'continue'] );
95 $cont_page = (int)$cont[0];
96 $pages = array_filter( $pages,
static function ( $v ) use ( $cont_page ) {
97 return $v >= $cont_page;
100 if ( $pages === [] ) {
107 $continuePages =
null;
108 if ( count( $pages ) > self::MAX_PAGES ) {
110 $pages = array_slice( $pages, 0, self::MAX_PAGES );
114 $revQuery = $this->revisionStore->getQueryInfo();
119 ?
'revactor_page' :
'rev_page';
121 ?
'revactor_actor' :
'rev_actor';
123 ?
'revactor_actor' :
'rev_actor';
129 'page' => $pageField,
130 'anons' =>
"COUNT(DISTINCT $countField)",
133 $this->
addWhere( $this->actorMigration->isAnon(
$revQuery[
'fields'][
'rev_user'] ) );
134 $this->
addWhere( $db->bitAnd(
'rev_deleted', RevisionRecord::DELETED_USER ) .
' = 0' );
135 $this->
addOption(
'GROUP BY', $pageField );
137 foreach (
$res as $row ) {
138 $fit = $result->addValue( [
'query',
'pages', $row->page ],
139 'anoncontributors', (
int)$row->anons
146 $params[
'continue'] ??
'0|0'
158 'page' => $pageField,
161 'userid' =>
'MAX(' .
$revQuery[
'fields'][
'rev_user'] .
')',
162 'username' =>
'MAX(' .
$revQuery[
'fields'][
'rev_user_text'] .
')',
165 $this->
addWhere( $this->actorMigration->isNotAnon(
$revQuery[
'fields'][
'rev_user'] ) );
166 $this->
addWhere( $db->bitAnd(
'rev_deleted', RevisionRecord::DELETED_USER ) .
' = 0' );
167 $this->
addOption(
'GROUP BY', [ $pageField, $idField ] );
168 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
172 if ( count( $pages ) > 1 ) {
173 $this->
addOption(
'ORDER BY', [
'page',
'id' ] );
179 if ( $params[
'group'] ) {
180 $excludeGroups =
false;
181 $limitGroups = $params[
'group'];
182 } elseif ( $params[
'excludegroup'] ) {
183 $excludeGroups =
true;
184 $limitGroups = $params[
'excludegroup'];
185 } elseif ( $params[
'rights'] ) {
186 $excludeGroups =
false;
187 foreach ( $params[
'rights'] as $r ) {
188 $limitGroups = array_merge( $limitGroups,
189 $this->groupPermissionsLookup->getGroupsWithPermission( $r ) );
193 if ( !$limitGroups ) {
194 if ( $continuePages !==
null ) {
202 } elseif ( $params[
'excluderights'] ) {
203 $excludeGroups =
true;
204 foreach ( $params[
'excluderights'] as $r ) {
205 $limitGroups = array_merge( $limitGroups,
206 $this->groupPermissionsLookup->getGroupsWithPermission( $r ) );
210 if ( $limitGroups ) {
211 $limitGroups = array_unique( $limitGroups );
214 $excludeGroups ?
'LEFT JOIN' :
'JOIN',
216 'ug_user=' .
$revQuery[
'fields'][
'rev_user'],
217 'ug_group' => $limitGroups,
218 'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
221 $this->
addWhereIf(
'ug_user IS NULL', $excludeGroups );
224 if ( $params[
'continue'] !==
null ) {
225 $cont = explode(
'|', $params[
'continue'] );
227 $cont_page = (int)$cont[0];
228 $cont_id = (int)$cont[1];
230 "$pageField > $cont_page OR " .
231 "($pageField = $cont_page AND " .
232 "$idField >= $cont_id)"
238 foreach (
$res as $row ) {
239 if ( ++$count > $params[
'limit'] ) {
247 [
'userid' => (
int)$row->userid,
'name' => $row->username ],
256 if ( $continuePages !==
null ) {
266 $userGroups = $this->userGroupManager->listAllGroups();
305 'action=query&prop=contributors&titles=Main_Page'
306 =>
'apihelp-query+contributors-example-simple',
311 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Contributors';
int $wgActorTableSchemaMigrationStage
Actor table schema migration stage, for migration from the temporary table revision_actor_temp to the...
const SCHEMA_COMPAT_READ_TEMP
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.