42 parent::__construct(
$query, $moduleName,
'pc' );
53 $pages = array_keys( $this->
getPageSet()->getGoodTitles() );
56 if (
$params[
'continue'] !==
null ) {
57 $cont = explode(
'|',
$params[
'continue'] );
59 $cont_page = (int)$cont[0];
60 $pages = array_filter( $pages,
function ( $v ) use ( $cont_page ) {
61 return $v >= $cont_page;
64 if ( !count( $pages ) ) {
71 $continuePages =
null;
72 if ( count( $pages ) > self::MAX_PAGES ) {
74 $pages = array_slice( $pages, 0, self::MAX_PAGES );
84 ?
'revactor_actor' :
$revQuery[
'fields'][
'rev_user'];
86 ?
'revactor_actor' :
$revQuery[
'fields'][
'rev_user_text'];
93 'anons' =>
"COUNT(DISTINCT $countField)",
96 $this->
addWhere( ActorMigration::newMigration()->isAnon(
$revQuery[
'fields'][
'rev_user'] ) );
97 $this->
addWhere( $db->bitAnd(
'rev_deleted', Revision::DELETED_USER ) .
' = 0' );
98 $this->
addOption(
'GROUP BY', $pageField );
100 foreach (
$res as $row ) {
101 $fit = $result->addValue( [
'query',
'pages', $row->page ],
102 'anoncontributors', (
int)$row->anons
121 'page' => $pageField,
124 'userid' =>
'MAX(' .
$revQuery[
'fields'][
'rev_user'] .
')',
125 'username' =>
'MAX(' .
$revQuery[
'fields'][
'rev_user_text'] .
')',
128 $this->
addWhere( ActorMigration::newMigration()->isNotAnon(
$revQuery[
'fields'][
'rev_user'] ) );
129 $this->
addWhere( $db->bitAnd(
'rev_deleted', Revision::DELETED_USER ) .
' = 0' );
130 $this->
addOption(
'GROUP BY', [ $pageField, $idField ] );
135 if ( count( $pages ) > 1 ) {
136 $this->
addOption(
'ORDER BY', [
'page',
'id' ] );
143 $excludeGroups =
false;
144 $limitGroups =
$params[
'group'];
145 } elseif (
$params[
'excludegroup'] ) {
146 $excludeGroups =
true;
147 $limitGroups =
$params[
'excludegroup'];
148 } elseif (
$params[
'rights'] ) {
149 $excludeGroups =
false;
150 foreach (
$params[
'rights'] as $r ) {
155 if ( !$limitGroups ) {
156 if ( $continuePages !==
null ) {
164 } elseif (
$params[
'excluderights'] ) {
165 $excludeGroups =
true;
166 foreach (
$params[
'excluderights'] as $r ) {
171 if ( $limitGroups ) {
172 $limitGroups = array_unique( $limitGroups );
175 $excludeGroups ?
'LEFT OUTER JOIN' :
'INNER 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';
int $wgActorTableSchemaMigrationStage
Actor table schema migration stage.
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
const LIMIT_BIG1
Fast query, standard limit.
getResult()
Get the result object.
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const LIMIT_BIG2
Fast query, apihighlimits limit.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
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)
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
addWhereFld( $field, $value)
Equivalent to addWhere(array($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.
getExamplesMessages()
Returns usage examples for this module.
__construct(ApiQuery $query, $moduleName)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getCacheMode( $params)
Get the cache mode for the data generated by this module.
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),...
This is the main query class.
static getAllGroups()
Return the set of defined explicit groups.
static getGroupsWithPermission( $role)
Get all the groups who have a given permission.
static getAllRights()
Get a list of all available permissions.
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like select() and insert() are usually more convenient. They take care of things like table prefixes and escaping for you. If you really need to make your own SQL
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query