Go to the documentation of this file.
35 parent::__construct(
$query, $moduleName,
'uc' );
48 $prop = array_flip( $this->params[
'prop'] );
49 $this->fld_ids = isset( $prop[
'ids'] );
50 $this->fld_title = isset( $prop[
'title'] );
51 $this->fld_comment = isset( $prop[
'comment'] );
52 $this->fld_parsedcomment = isset( $prop[
'parsedcomment'] );
53 $this->fld_size = isset( $prop[
'size'] );
54 $this->fld_sizediff = isset( $prop[
'sizediff'] );
55 $this->fld_flags = isset( $prop[
'flags'] );
56 $this->fld_timestamp = isset( $prop[
'timestamp'] );
57 $this->fld_patrolled = isset( $prop[
'patrolled'] );
58 $this->fld_tags = isset( $prop[
'tags'] );
63 $dbSecondary = $this->
getDB();
70 $this->idMode =
false;
71 if ( isset( $this->params[
'userprefix'] ) ) {
72 $this->prefixMode =
true;
73 $this->multiUserMode =
true;
74 $this->userprefix = $this->params[
'userprefix'];
75 } elseif ( isset( $this->params[
'userids'] ) ) {
78 if ( !
count( $this->params[
'userids'] ) ) {
80 $this->
dieWithError( [
'apierror-paramempty', $encParamName ],
"paramempty_$encParamName" );
83 foreach ( $this->params[
'userids']
as $uid ) {
85 $this->
dieWithError( [
'apierror-invaliduserid', $uid ],
'invaliduserid' );
88 $this->userids[] = $uid;
91 $this->prefixMode =
false;
92 $this->multiUserMode = (
count( $this->params[
'userids'] ) > 1 );
97 $this->usernames = [];
98 if ( !
count( $this->params[
'user'] ) ) {
101 [
'apierror-paramempty', $encParamName ],
"paramempty_$encParamName"
104 foreach ( $this->params[
'user']
as $u ) {
108 [
'apierror-paramempty', $encParamName ],
"paramempty_$encParamName"
114 $this->usernames[] = $u;
117 if (
$name ===
false ) {
120 [
'apierror-baduser', $encParamName,
wfEscapeWikiText( $u ) ],
"baduser_$encParamName"
123 $this->usernames[] =
$name;
126 $this->prefixMode =
false;
127 $this->multiUserMode = (
count( $this->params[
'user'] ) > 1 );
131 $res =
$dbr->select(
'user',
'user_id', [
'user_name' => $this->usernames ], __METHOD__ );
132 foreach (
$res as $row ) {
133 $this->userids[] = $row->user_id;
135 $this->idMode =
count( $this->userids ) ===
count( $this->usernames );
143 $res = $this->
select( __METHOD__, [], $hookData );
145 if ( $this->fld_sizediff ) {
147 foreach (
$res as $row ) {
148 if ( $row->rev_parent_id ) {
149 $revIds[] = $row->rev_parent_id;
158 $limit = $this->params[
'limit'];
161 foreach (
$res as $row ) {
162 if ( ++$count >
$limit ) {
170 $fit = $this->
processRow( $row, $vals, $hookData ) &&
192 $tables = [
'page',
'revision' ];
193 $this->
addWhere(
'page_id=rev_page' );
196 if ( !is_null( $this->params[
'continue'] ) ) {
197 $continue = explode(
'|', $this->params[
'continue'] );
198 $db = $this->
getDB();
199 if ( $this->multiUserMode ) {
201 $modeFlag = array_shift( $continue );
203 if ( $this->idMode && $modeFlag ===
'name' ) {
207 $this->idMode =
false;
210 $userField = $this->idMode ?
'rev_user' :
'rev_user_text';
211 $encUser = $db->addQuotes( array_shift( $continue ) );
215 $encTS = $db->addQuotes( $db->timestamp( $continue[0] ) );
216 $encId = (int)$continue[1];
218 $op = ( $this->params[
'dir'] ==
'older' ?
'<' :
'>' );
219 if ( $this->multiUserMode ) {
221 "$userField $op $encUser OR " .
222 "($userField = $encUser AND " .
223 "(rev_timestamp $op $encTS OR " .
224 "(rev_timestamp = $encTS AND " .
225 "rev_id $op= $encId)))"
229 "rev_timestamp $op $encTS OR " .
230 "(rev_timestamp = $encTS AND " .
231 "rev_id $op= $encId)"
238 if ( !
$user->isAllowed(
'deletedhistory' ) ) {
240 } elseif ( !
$user->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
246 $this->
addWhere( $this->
getDB()->bitAnd(
'rev_deleted', $bitmask ) .
" != $bitmask" );
250 if ( $this->prefixMode ) {
252 $this->
getDB()->buildLike( $this->userprefix, $this->
getDB()->anyString() ) );
253 } elseif ( $this->idMode ) {
256 $this->
addWhereFld(
'rev_user_text', $this->usernames );
261 if ( $this->multiUserMode ) {
262 $this->
addWhereRange( $this->idMode ?
'rev_user' :
'rev_user_text',
263 $this->params[
'dir'],
null,
null );
266 $this->params[
'dir'], $this->params[
'start'], $this->params[
'end'] );
268 $this->
addWhereRange(
'rev_id', $this->params[
'dir'],
null,
null );
270 $this->
addWhereFld(
'page_namespace', $this->params[
'namespace'] );
272 $show = $this->params[
'show'];
273 if ( $this->params[
'toponly'] ) {
276 if ( !is_null( $show ) ) {
277 $show = array_flip( $show );
279 if ( ( isset( $show[
'minor'] ) && isset( $show[
'!minor'] ) )
280 || ( isset( $show[
'patrolled'] ) && isset( $show[
'!patrolled'] ) )
281 || ( isset( $show[
'top'] ) && isset( $show[
'!top'] ) )
282 || ( isset( $show[
'new'] ) && isset( $show[
'!new'] ) )
287 $this->
addWhereIf(
'rev_minor_edit = 0', isset( $show[
'!minor'] ) );
288 $this->
addWhereIf(
'rev_minor_edit != 0', isset( $show[
'minor'] ) );
289 $this->
addWhereIf(
'rc_patrolled = 0', isset( $show[
'!patrolled'] ) );
290 $this->
addWhereIf(
'rc_patrolled != 0', isset( $show[
'patrolled'] ) );
291 $this->
addWhereIf(
'rev_id != page_latest', isset( $show[
'!top'] ) );
292 $this->
addWhereIf(
'rev_id = page_latest', isset( $show[
'top'] ) );
293 $this->
addWhereIf(
'rev_parent_id != 0', isset( $show[
'!new'] ) );
294 $this->
addWhereIf(
'rev_parent_id = 0', isset( $show[
'new'] ) );
296 $this->
addOption(
'LIMIT', $this->params[
'limit'] + 1 );
311 if ( isset( $show[
'patrolled'] ) || isset( $show[
'!patrolled'] ) ||
314 if ( !
$user->useRCPatrol() && !
$user->useNPPatrol() ) {
315 $this->
dieWithError(
'apierror-permissiondenied-patrolflag',
'permissiondenied' );
321 $index[
'recentchanges'] =
'rc_user_text';
322 if ( isset( $show[
'patrolled'] ) || isset( $show[
'!patrolled'] ) ) {
325 $tables = [
'revision',
'recentchanges',
'page' ];
327 $this->
addWhere(
'rc_user_text=rev_user_text' );
328 $this->
addWhere(
'rc_timestamp=rev_timestamp' );
329 $this->
addWhere(
'rc_this_oldid=rev_id' );
334 'rc_user_text=rev_user_text',
335 'rc_timestamp=rev_timestamp',
336 'rc_this_oldid=rev_id' ] ] ] );
342 $this->
addFieldsIf(
'page_latest', $this->fld_flags );
344 $this->
addFieldsIf(
'rev_comment', $this->fld_comment || $this->fld_parsedcomment );
345 $this->
addFieldsIf(
'rev_len', $this->fld_size || $this->fld_sizediff );
346 $this->
addFieldsIf(
'rev_minor_edit', $this->fld_flags );
347 $this->
addFieldsIf(
'rev_parent_id', $this->fld_flags || $this->fld_sizediff || $this->fld_ids );
348 $this->
addFieldsIf(
'rc_patrolled', $this->fld_patrolled );
350 if ( $this->fld_tags ) {
353 [
'tag_summary' => [
'LEFT JOIN', [
'rev_id=ts_rev_id' ] ] ]
358 if ( isset( $this->params[
'tag'] ) ) {
361 [
'change_tag' => [
'INNER JOIN', [
'rev_id=ct_rev_id' ] ] ]
363 $this->
addWhereFld(
'ct_tag', $this->params[
'tag'] );
366 if ( isset( $index ) ) {
382 $vals[
'texthidden'] =
true;
387 $vals[
'userid'] = (int)$row->rev_user;
388 $vals[
'user'] = $row->rev_user_text;
390 $vals[
'userhidden'] =
true;
393 if ( $this->fld_ids ) {
394 $vals[
'pageid'] = intval( $row->rev_page );
395 $vals[
'revid'] = intval( $row->rev_id );
398 if ( !is_null( $row->rev_parent_id ) ) {
399 $vals[
'parentid'] = intval( $row->rev_parent_id );
405 if ( $this->fld_title ) {
409 if ( $this->fld_timestamp ) {
410 $vals[
'timestamp'] =
wfTimestamp( TS_ISO_8601, $row->rev_timestamp );
413 if ( $this->fld_flags ) {
414 $vals[
'new'] = $row->rev_parent_id == 0 && !is_null( $row->rev_parent_id );
415 $vals[
'minor'] = (bool)$row->rev_minor_edit;
416 $vals[
'top'] = $row->page_latest == $row->rev_id;
419 if ( ( $this->fld_comment || $this->fld_parsedcomment ) && isset( $row->rev_comment ) ) {
421 $vals[
'commenthidden'] =
true;
430 if ( $userCanView ) {
431 if ( $this->fld_comment ) {
432 $vals[
'comment'] = $row->rev_comment;
435 if ( $this->fld_parsedcomment ) {
441 if ( $this->fld_patrolled ) {
442 $vals[
'patrolled'] = (bool)$row->rc_patrolled;
445 if ( $this->fld_size && !is_null( $row->rev_len ) ) {
446 $vals[
'size'] = intval( $row->rev_len );
449 if ( $this->fld_sizediff
450 && !is_null( $row->rev_len )
451 && !is_null( $row->rev_parent_id )
453 $parentLen = isset( $this->parentLens[$row->rev_parent_id] )
454 ? $this->parentLens[$row->rev_parent_id]
456 $vals[
'sizediff'] = intval( $row->rev_len - $parentLen );
459 if ( $this->fld_tags ) {
460 if ( $row->ts_tags ) {
461 $tags = explode(
',', $row->ts_tags );
463 $vals[
'tags'] = $tags;
470 $vals[
'suppressed'] =
true;
477 if ( $this->multiUserMode ) {
478 if ( $this->idMode ) {
479 return "id|$row->rev_user|$row->rev_timestamp|$row->rev_id";
481 return "name|$row->rev_user_text|$row->rev_timestamp|$row->rev_id";
484 return "$row->rev_timestamp|$row->rev_id";
491 return 'anon-public-user-private';
520 'userprefix' =>
null,
563 'apihelp-query+usercontribs-param-show',
577 'action=query&list=usercontribs&ucuser=Example'
578 =>
'apihelp-query+usercontribs-example-user',
579 'action=query&list=usercontribs&ucuserprefix=192.0.2.'
580 =>
'apihelp-query+usercontribs-example-ipprefix',
585 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Usercontribs';
getConfig()
Get the Config object.
processRow( $row, array &$data, array &$hookData)
Call the ApiQueryBaseProcessRow hook.
addFields( $value)
Add a set of fields to select to the internal array.
This is the main query class.
static userCanBitfield( $bitfield, $field, User $user=null, Title $title=null)
Determine if the current user is allowed to view a particular field of this revision,...
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
addTimestampWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getResult()
Get the result object.
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
Allows to change the fields on the form that will be generated $name
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
getUser()
Get the User object.
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
null for the 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
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
namespace and then decline to actually register it file or subcat img or subcat $title
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'.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers please use GetContentModels hook to make them known to core if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
getExamplesMessages()
Returns usage examples for this module.
static isIP( $name)
Does the string match an anonymous IP address?
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.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
getHelpUrls()
Return links to more detailed help pages about the module.
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,...
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
extractRowInfo( $row)
Extract fields from the database row and append them to a result array.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
addWhereFld( $field, $value)
Equivalent to addWhere(array($field => $value))
requireOnlyOneParameter( $params, $required)
Die if none or more than one of a certain set of parameters is set and not false.
static formatComment( $comment, $title=null, $local=false, $wikiId=null)
This function is called by all recent changes variants, by the page history, and by the user contribu...
selectNamedDB( $name, $db, $groups)
Selects the query database connection with the given name.
const LIMIT_BIG2
Fast query, apihighlimits limit.
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
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.
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,...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
addWhere( $value)
Add a set of WHERE clauses to the internal array.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
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.
__construct(ApiQuery $query, $moduleName)
This query action adds a list of a specified user's contributions to the output.