Go to the documentation of this file.
35 parent::__construct(
$query, $moduleName,
'uc' );
47 $prop = array_flip( $this->params[
'prop'] );
48 $this->fld_ids = isset( $prop[
'ids'] );
49 $this->fld_title = isset( $prop[
'title'] );
50 $this->fld_comment = isset( $prop[
'comment'] );
51 $this->fld_parsedcomment = isset( $prop[
'parsedcomment'] );
52 $this->fld_size = isset( $prop[
'size'] );
53 $this->fld_sizediff = isset( $prop[
'sizediff'] );
54 $this->fld_flags = isset( $prop[
'flags'] );
55 $this->fld_timestamp = isset( $prop[
'timestamp'] );
56 $this->fld_patrolled = isset( $prop[
'patrolled'] );
57 $this->fld_tags = isset( $prop[
'tags'] );
62 $dbSecondary = $this->
getDB();
67 if ( isset( $this->params[
'userprefix'] ) ) {
68 $this->prefixMode =
true;
69 $this->multiUserMode =
true;
70 $this->userprefix = $this->params[
'userprefix'];
72 $this->usernames =
array();
73 if ( !is_array( $this->params[
'user'] ) ) {
74 $this->params[
'user'] =
array( $this->params[
'user'] );
76 if ( !count( $this->params[
'user'] ) ) {
77 $this->
dieUsage(
'User parameter may not be empty.',
'param_user' );
79 foreach ( $this->params[
'user']
as $u ) {
82 $this->prefixMode =
false;
83 $this->multiUserMode = ( count( $this->params[
'user'] ) > 1 );
91 if ( $this->fld_sizediff ) {
94 if ( $row->rev_parent_id ) {
95 $revIds[] = $row->rev_parent_id;
104 $limit = $this->params[
'limit'];
107 foreach (
$res as $row ) {
123 $this->
getResult()->setIndexedTagName_internal(
140 if (
$name ===
false ) {
141 $this->
dieUsage(
"User name {$user} is not valid",
'param_user' );
143 $this->usernames[] =
$name;
146 $this->
dieUsage(
'User parameter may not be empty',
'param_user' );
159 $this->
addWhere(
'page_id=rev_page' );
162 if ( !is_null( $this->params[
'continue'] ) ) {
163 $continue = explode(
'|', $this->params[
'continue'] );
164 $db = $this->
getDB();
165 if ( $this->multiUserMode ) {
167 $encUser = $db->addQuotes( array_shift( $continue ) );
171 $encTS = $db->addQuotes( $db->timestamp( $continue[0] ) );
172 $encId = (int)$continue[1];
174 $op = ( $this->params[
'dir'] ==
'older' ?
'<' :
'>' );
175 if ( $this->multiUserMode ) {
177 "rev_user_text $op $encUser OR " .
178 "(rev_user_text = $encUser AND " .
179 "(rev_timestamp $op $encTS OR " .
180 "(rev_timestamp = $encTS AND " .
181 "rev_id $op= $encId)))"
185 "rev_timestamp $op $encTS OR " .
186 "(rev_timestamp = $encTS AND " .
187 "rev_id $op= $encId)"
194 if ( !
$user->isAllowed(
'deletedhistory' ) ) {
196 } elseif ( !
$user->isAllowed(
'suppressrevision' ) ) {
202 $this->
addWhere( $this->
getDB()->bitAnd(
'rev_deleted', $bitmask ) .
" != $bitmask" );
206 if ( $this->prefixMode ) {
208 $this->
getDB()->buildLike( $this->userprefix, $this->
getDB()->anyString() ) );
210 $this->
addWhereFld(
'rev_user_text', $this->usernames );
215 if ( $this->multiUserMode ) {
216 $this->
addWhereRange(
'rev_user_text', $this->params[
'dir'],
null,
null );
219 $this->params[
'dir'], $this->params[
'start'], $this->params[
'end'] );
221 $this->
addWhereRange(
'rev_id', $this->params[
'dir'],
null,
null );
223 $this->
addWhereFld(
'page_namespace', $this->params[
'namespace'] );
225 $show = $this->params[
'show'];
226 if ( $this->params[
'toponly'] ) {
229 if ( !is_null( $show ) ) {
230 $show = array_flip( $show );
232 if ( ( isset( $show[
'minor'] ) && isset( $show[
'!minor'] ) )
233 || ( isset( $show[
'patrolled'] ) && isset( $show[
'!patrolled'] ) )
234 || ( isset( $show[
'top'] ) && isset( $show[
'!top'] ) )
235 || ( isset( $show[
'new'] ) && isset( $show[
'!new'] ) )
240 $this->
addWhereIf(
'rev_minor_edit = 0', isset( $show[
'!minor'] ) );
241 $this->
addWhereIf(
'rev_minor_edit != 0', isset( $show[
'minor'] ) );
242 $this->
addWhereIf(
'rc_patrolled = 0', isset( $show[
'!patrolled'] ) );
243 $this->
addWhereIf(
'rc_patrolled != 0', isset( $show[
'patrolled'] ) );
244 $this->
addWhereIf(
'rev_id != page_latest', isset( $show[
'!top'] ) );
245 $this->
addWhereIf(
'rev_id = page_latest', isset( $show[
'top'] ) );
246 $this->
addWhereIf(
'rev_parent_id != 0', isset( $show[
'!new'] ) );
247 $this->
addWhereIf(
'rev_parent_id = 0', isset( $show[
'new'] ) );
249 $this->
addOption(
'LIMIT', $this->params[
'limit'] + 1 );
250 $index =
array(
'revision' =>
'usertext_timestamp' );
265 if ( isset( $show[
'patrolled'] ) || isset( $show[
'!patrolled'] ) ||
268 if ( !
$user->useRCPatrol() && !
$user->useNPPatrol() ) {
270 'You need the patrol right to request the patrolled flag',
278 $index[
'recentchanges'] =
'rc_user_text';
279 if ( isset( $show[
'patrolled'] ) || isset( $show[
'!patrolled'] ) ) {
284 $this->
addWhere(
'rc_user_text=rev_user_text' );
285 $this->
addWhere(
'rc_timestamp=rev_timestamp' );
286 $this->
addWhere(
'rc_this_oldid=rev_id' );
291 'rc_user_text=rev_user_text',
292 'rc_timestamp=rev_timestamp',
293 'rc_this_oldid=rev_id' ) ) ) );
299 $this->
addFieldsIf(
'page_latest', $this->fld_flags );
301 $this->
addFieldsIf(
'rev_comment', $this->fld_comment || $this->fld_parsedcomment );
302 $this->
addFieldsIf(
'rev_len', $this->fld_size || $this->fld_sizediff );
303 $this->
addFieldsIf(
'rev_minor_edit', $this->fld_flags );
304 $this->
addFieldsIf(
'rev_parent_id', $this->fld_flags || $this->fld_sizediff || $this->fld_ids );
305 $this->
addFieldsIf(
'rc_patrolled', $this->fld_patrolled );
307 if ( $this->fld_tags ) {
310 array(
'tag_summary' =>
array(
'LEFT JOIN',
array(
'rev_id=ts_rev_id' ) ) )
315 if ( isset( $this->params[
'tag'] ) ) {
318 array(
'change_tag' =>
array(
'INNER JOIN',
array(
'rev_id=ct_rev_id' ) ) )
320 $this->
addWhereFld(
'ct_tag', $this->params[
'tag'] );
337 $vals[
'texthidden'] =
'';
342 $vals[
'userid'] = $row->rev_user;
343 $vals[
'user'] = $row->rev_user_text;
345 $vals[
'userhidden'] =
'';
348 if ( $this->fld_ids ) {
349 $vals[
'pageid'] = intval( $row->rev_page );
350 $vals[
'revid'] = intval( $row->rev_id );
353 if ( !is_null( $row->rev_parent_id ) ) {
354 $vals[
'parentid'] = intval( $row->rev_parent_id );
360 if ( $this->fld_title ) {
364 if ( $this->fld_timestamp ) {
368 if ( $this->fld_flags ) {
369 if ( $row->rev_parent_id == 0 && !is_null( $row->rev_parent_id ) ) {
372 if ( $row->rev_minor_edit ) {
375 if ( $row->page_latest == $row->rev_id ) {
380 if ( ( $this->fld_comment || $this->fld_parsedcomment ) && isset( $row->rev_comment ) ) {
382 $vals[
'commenthidden'] =
'';
391 if ( $userCanView ) {
392 if ( $this->fld_comment ) {
393 $vals[
'comment'] = $row->rev_comment;
396 if ( $this->fld_parsedcomment ) {
402 if ( $this->fld_patrolled && $row->rc_patrolled ) {
403 $vals[
'patrolled'] =
'';
406 if ( $this->fld_size && !is_null( $row->rev_len ) ) {
407 $vals[
'size'] = intval( $row->rev_len );
410 if ( $this->fld_sizediff
411 && !is_null( $row->rev_len )
412 && !is_null( $row->rev_parent_id )
414 $parentLen = isset( $this->parentLens[$row->rev_parent_id] )
415 ? $this->parentLens[$row->rev_parent_id]
417 $vals[
'sizediff'] = intval( $row->rev_len - $parentLen );
420 if ( $this->fld_tags ) {
421 if ( $row->ts_tags ) {
422 $tags = explode(
',', $row->ts_tags );
423 $this->
getResult()->setIndexedTagName( $tags,
'tag' );
424 $vals[
'tags'] = $tags;
426 $vals[
'tags'] =
array();
431 $vals[
'suppressed'] =
'';
438 if ( $this->multiUserMode ) {
439 return "$row->rev_user_text|$row->rev_timestamp|$row->rev_id";
441 return "$row->rev_timestamp|$row->rev_id";
448 return 'anon-public-user-private';
470 'userprefix' =>
null,
478 'namespace' =>
array(
524 'limit' =>
'The maximum number of contributions to return',
525 'start' =>
'The start timestamp to return from',
526 'end' =>
'The end timestamp to return to',
527 'continue' =>
'When more results are available, use this to continue',
528 'user' =>
'The users to retrieve contributions for',
529 'userprefix' =>
array(
530 "Retrieve contributions for all users whose names begin with this value.",
531 "Overrides {$p}user",
534 'namespace' =>
'Only list contributions in these namespaces',
536 'Include additional pieces of information',
537 ' ids - Adds the page ID and revision ID',
538 ' title - Adds the title and namespace ID of the page',
539 ' timestamp - Adds the timestamp of the edit',
540 ' comment - Adds the comment of the edit',
541 ' parsedcomment - Adds the parsed comment of the edit',
542 ' size - Adds the new size of the edit',
543 ' sizediff - Adds the size delta of the edit against its parent',
544 ' flags - Adds flags of the edit',
545 ' patrolled - Tags patrolled edits',
546 ' tags - Lists tags for the edit',
549 "Show only items that meet thse criteria, e.g. non minor edits only: {$p}show=!minor",
550 "NOTE: If {$p}show=patrolled or {$p}show=!patrolled is set, revisions older than",
551 "\$wgRCMaxAge ($wgRCMaxAge) won't be shown",
553 'tag' =>
'Only list revisions tagged with this tag',
554 'toponly' =>
'Only list changes which are the latest revision',
561 'userid' =>
'integer',
563 'userhidden' =>
'boolean'
566 'pageid' =>
'integer',
567 'revid' =>
'integer',
577 'timestamp' =>
array(
578 'timestamp' =>
'timestamp'
582 'minor' =>
'boolean',
586 'commenthidden' =>
'boolean',
592 'parsedcomment' =>
array(
593 'commenthidden' =>
'boolean',
594 'parsedcomment' =>
array(
599 'patrolled' =>
array(
600 'patrolled' =>
'boolean'
618 return 'Get all edits by a user.';
622 return array_merge( parent::getPossibleErrors(),
array(
623 array(
'code' =>
'param_user',
'info' =>
'User parameter may not be empty.' ),
624 array(
'code' =>
'param_user',
'info' =>
'User name user is not valid' ),
627 'code' =>
'permissiondenied',
628 'info' =>
'You need the patrol right to request the patrolled flag'
635 'api.php?action=query&list=usercontribs&ucuser=YurikBot',
636 'api.php?action=query&list=usercontribs&ucuserprefix=217.121.114.',
641 return 'https://www.mediawiki.org/wiki/API:Usercontribs';
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
addFields( $value)
Add a set of fields to select to the internal array.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
addTimestampWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
dieUsageMsg( $error)
Output the error message related to a certain array.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
getResult()
Get the result object.
select( $method, $extraQuery=array())
Execute a SELECT query based on the values in the internal arrays.
getDirectionDescription( $p='', $extraDirText='')
Gets the personalised direction parameter description.
static userCanBitfield( $bitfield, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this revision,...
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
static formatComment( $comment, $title=null, $local=false)
This function is called by all recent changes variants, by the page history, and by the user contribu...
getParamDescription()
Returns an array of parameter descriptions.
getDescription()
Returns the description string for this module.
getUser()
Get the User object.
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
This is a base class for all Query modules.
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
getDB()
Get the Query database connection (read-only)
static isIP( $name)
Does the string match an anonymous IPv4 address?
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
addWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, and an ORDER BY clause to sort in the right direction.
prepareQuery()
Prepares the query and returns the limit of rows requested.
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
presenting them properly to the user as errors is done by the caller $title
Allows to change the fields on the form that will be generated $name
getResultProperties()
Returns possible properties in the result, grouped by the value of the prop parameter that shows them...
dieContinueUsageIf( $condition)
Die with the $prefix.
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
dieUsage( $description, $errorCode, $httpRespCode=0, $extradata=null)
Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an...
extractRowInfo( $row)
Extract fields from the database row and append them to a result array.
prepareUsername( $user)
Validate the 'user' parameter and set the value to compare against revision.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
addWhereFld( $field, $value)
Equivalent to addWhere(array($field => $value))
__construct( $query, $moduleName)
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
selectNamedDB( $name, $db, $groups)
Selects the query database connection with the given name.
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
getModuleName()
Get the name of the module being executed by this instance.
addWhere( $value)
Add a set of WHERE clauses to the internal array.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
getExamples()
Returns usage examples for this module.
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
addWhereIf( $value, $condition)
Same as addWhere(), but add the WHERE clauses only if a condition is met.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
This query action adds a list of a specified user's contributions to the output.