Go to the documentation of this file.
45 parent::__construct( $query, $moduleName,
'pc' );
54 $pages = array_keys( $this->
getPageSet()->getGoodTitles() );
57 if ( $params[
'continue'] !==
null ) {
58 $cont = explode(
'|', $params[
'continue'] );
60 $cont_page = (int)$cont[0];
61 $pages = array_filter( $pages,
function ( $v ) use ( $cont_page ) {
62 return $v >= $cont_page;
65 if ( $pages === [] ) {
72 $continuePages =
null;
73 if ( count( $pages ) > self::MAX_PAGES ) {
75 $pages = array_slice( $pages, 0, self::MAX_PAGES );
79 $revQuery = MediaWikiServices::getInstance()->getRevisionStore()->getQueryInfo();
82 $pageField =
'revactor_page';
83 $idField =
'revactor_actor';
84 $countField =
'revactor_actor';
91 'anons' =>
"COUNT(DISTINCT $countField)",
95 $this->
addWhere( $db->bitAnd(
'rev_deleted', RevisionRecord::DELETED_USER ) .
' = 0' );
96 $this->
addOption(
'GROUP BY', $pageField );
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'] .
')',
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 ) {
150 ->getGroupsWithPermission( $r ) );
154 if ( !$limitGroups ) {
155 if ( $continuePages !==
null ) {
163 } elseif ( $params[
'excluderights'] ) {
164 $excludeGroups =
true;
165 foreach ( $params[
'excluderights'] as $r ) {
167 ->getGroupsWithPermission( $r ) );
171 if ( $limitGroups ) {
172 $limitGroups = array_unique( $limitGroups );
175 $excludeGroups ?
'LEFT JOIN' :
'JOIN',
177 'ug_user=' .
$revQuery[
'fields'][
'rev_user'],
178 'ug_group' => $limitGroups,
179 'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
182 $this->
addWhereIf(
'ug_user IS NULL', $excludeGroups );
185 if ( $params[
'continue'] !==
null ) {
186 $cont = explode(
'|', $params[
'continue'] );
188 $cont_page = (int)$cont[0];
189 $cont_id = (int)$cont[1];
191 "$pageField > $cont_page OR " .
192 "($pageField = $cont_page AND " .
193 "$idField >= $cont_id)"
199 foreach (
$res as $row ) {
200 if ( ++$count > $params[
'limit'] ) {
208 [
'userid' => (
int)$row->userid,
'name' => $row->username ],
217 if ( $continuePages !==
null ) {
262 'action=query&prop=contributors&titles=Main_Page'
263 =>
'apihelp-query+contributors-example-simple',
268 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Contributors';
A query module to show contributors to a page.
addFields( $value)
Add a set of fields to select to the internal array.
This is the main query class.
const MAX_PAGES
We don't want to process too many pages at once (it hits cold database pages too heavily),...
resetQueryParams()
Blank the internal arrays with query parameters.
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getResult()
Get the result object.
__construct(ApiQuery $query, $moduleName)
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
static newMigration()
Static constructor.
getExamplesMessages()
Returns usage examples for this module.
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
This is a base class for all Query modules.
const LIMIT_BIG1
Fast query, standard limit.
getDB()
Get the Query database connection (read-only)
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
addWhereFld( $field, $value)
Equivalent to addWhere( [ $field => $value ] )
static getAllGroups()
Return the set of defined explicit groups.
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
getPageSet()
Get the PageSet object to work on.
getHelpUrls()
Return links to more detailed help pages about the module.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
const LIMIT_BIG2
Fast query, apihighlimits limit.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
addWhere( $value)
Add a set of WHERE clauses to the internal array.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
addPageSubItem( $pageId, $item, $elemname=null)
Same as addPageSubItems(), but one element of $data at a time.
addWhereIf( $value, $condition)
Same as addWhere(), but add the WHERE clauses only if a condition is met.