44 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 );
83 'anons' =>
'COUNT(DISTINCT rev_user_text)',
88 $this->
addOption(
'GROUP BY',
'rev_page' );
90 foreach (
$res as $row ) {
91 $fit = $result->addValue( [
'query',
'pages', $row->page ],
92 'anoncontributors', (
int)$row->anons
110 'page' =>
'rev_page',
111 'user' =>
'rev_user',
112 'username' =>
'MAX(rev_user_text)',
117 $this->
addOption(
'GROUP BY',
'rev_page, rev_user' );
122 if ( count( $pages ) > 1 ) {
123 $this->
addOption(
'ORDER BY',
'rev_page, rev_user' );
125 $this->
addOption(
'ORDER BY',
'rev_user' );
130 $excludeGroups =
false;
131 $limitGroups =
$params[
'group'];
132 } elseif (
$params[
'excludegroup'] ) {
133 $excludeGroups =
true;
134 $limitGroups =
$params[
'excludegroup'];
135 } elseif (
$params[
'rights'] ) {
136 $excludeGroups =
false;
137 foreach (
$params[
'rights'] as $r ) {
138 $limitGroups = array_merge( $limitGroups, User::getGroupsWithPermission( $r ) );
142 if ( !$limitGroups ) {
143 if ( $continuePages !==
null ) {
151 } elseif (
$params[
'excluderights'] ) {
152 $excludeGroups =
true;
153 foreach (
$params[
'excluderights'] as $r ) {
154 $limitGroups = array_merge( $limitGroups, User::getGroupsWithPermission( $r ) );
158 if ( $limitGroups ) {
159 $limitGroups = array_unique( $limitGroups );
162 $excludeGroups ?
'LEFT OUTER JOIN' :
'INNER JOIN',
165 'ug_group' => $limitGroups,
166 'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
169 $this->
addWhereIf(
'ug_user IS NULL', $excludeGroups );
172 if (
$params[
'continue'] !==
null ) {
173 $cont = explode(
'|',
$params[
'continue'] );
175 $cont_page = (int)$cont[0];
176 $cont_user = (int)$cont[1];
178 "rev_page > $cont_page OR " .
179 "(rev_page = $cont_page AND " .
180 "rev_user >= $cont_user)"
186 foreach (
$res as $row ) {
187 if ( ++$count >
$params[
'limit'] ) {
196 [
'userid' => (
int)$row->user,
'name' => $row->username ],
206 if ( $continuePages !==
null ) {
216 $userGroups = User::getAllGroups();
217 $userRights = User::getAllRights();
251 'action=query&prop=contributors&titles=Main_Page'
252 =>
'apihelp-query+contributors-example-simple',
257 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Contributors';
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.
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