Go to the documentation of this file.
36 parent::__construct( $query, $moduleName,
'le' );
50 $prop = array_flip( $params[
'prop'] );
52 $this->fld_ids = isset( $prop[
'ids'] );
53 $this->fld_title = isset( $prop[
'title'] );
54 $this->fld_type = isset( $prop[
'type'] );
55 $this->fld_user = isset( $prop[
'user'] );
56 $this->fld_userid = isset( $prop[
'userid'] );
57 $this->fld_timestamp = isset( $prop[
'timestamp'] );
58 $this->fld_comment = isset( $prop[
'comment'] );
59 $this->fld_parsedcomment = isset( $prop[
'parsedcomment'] );
60 $this->fld_details = isset( $prop[
'details'] );
61 $this->fld_tags = isset( $prop[
'tags'] );
64 if ( $hideLogs !==
false ) {
69 $actorQuery = $actorMigration->getJoin(
'log_user' );
71 $this->
addTables( $actorQuery[
'tables'] );
75 'user' => [
'LEFT JOIN',
76 'user_id=' . $actorQuery[
'fields'][
'log_user'] ],
77 'page' => [
'LEFT JOIN',
78 [
'log_namespace=page_namespace',
79 'log_title=page_title' ] ] ] );
94 $this->
addFieldsIf( $actorQuery[
'fields'] + [
'user_name' ], $this->fld_user );
95 $this->
addFieldsIf( $actorQuery[
'fields'], $this->fld_userid );
97 [
'log_namespace',
'log_title' ],
98 $this->fld_title || $this->fld_parsedcomment
100 $this->
addFieldsIf(
'log_params', $this->fld_details );
102 if ( $this->fld_comment || $this->fld_parsedcomment ) {
103 $commentQuery = $this->commentStore->getJoin(
'log_comment' );
104 $this->
addTables( $commentQuery[
'tables'] );
105 $this->
addFields( $commentQuery[
'fields'] );
109 if ( $this->fld_tags ) {
113 if ( !is_null( $params[
'tag'] ) ) {
116 [
'log_id=ct_log_id' ] ] ] );
117 $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
119 $this->
addWhereFld(
'ct_tag_id', $changeTagDefStore->getId( $params[
'tag'] ) );
126 if ( !is_null( $params[
'action'] ) ) {
129 $logAction = $params[
'action'];
130 if ( strpos( $logAction,
'/' ) ===
false ) {
135 list(
$type, $action ) = explode(
'/', $logAction, 2 );
136 $valid = isset( $logActions[$logAction] ) || isset( $logActions[
$type .
'/*'] );
142 [
'apierror-unrecognizedvalue', $encParamName,
wfEscapeWikiText( $logAction ) ],
143 "unknown_$encParamName"
149 } elseif ( !is_null( $params[
'type'] ) ) {
160 $this->
addWhereRange(
'log_id', $params[
'dir'],
null,
null );
162 if ( !is_null( $params[
'continue'] ) ) {
163 $cont = explode(
'|', $params[
'continue'] );
165 $op = ( $params[
'dir'] ===
'newer' ?
'>' :
'<' );
166 $continueTimestamp = $db->addQuotes( $db->timestamp( $cont[0] ) );
167 $continueId = (int)$cont[1];
169 $this->
addWhere(
"log_timestamp $op $continueTimestamp OR " .
170 "(log_timestamp = $continueTimestamp AND " .
171 "log_id $op= $continueId)"
175 $limit = $params[
'limit'];
178 $user = $params[
'user'];
179 if ( !is_null( $user ) ) {
182 $q = $actorMigration->getWhere(
190 $this->
addOption(
'IGNORE INDEX', [
'logging' => [
'times' ] ] );
193 $title = $params[
'title'];
194 if ( !is_null(
$title ) ) {
196 if ( is_null( $titleObj ) ) {
199 $this->
addWhereFld(
'log_namespace', $titleObj->getNamespace() );
200 $this->
addWhereFld(
'log_title', $titleObj->getDBkey() );
203 if ( $params[
'namespace'] !==
null ) {
204 $this->
addWhereFld(
'log_namespace', $params[
'namespace'] );
207 $prefix = $params[
'prefix'];
209 if ( !is_null( $prefix ) ) {
210 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
215 if ( is_null(
$title ) ) {
219 $this->
addWhere(
'log_title ' . $db->buildLike(
$title->getDBkey(), $db->anyString() ) );
223 if ( $params[
'namespace'] !==
null || !is_null(
$title ) || !is_null( $user ) ) {
228 ->userHasAnyRight( $this->
getUser(),
'suppressrevision',
'viewsuppressed' )
236 if ( ( $params[
'namespace'] !==
null || !is_null(
$title ) ) && $titleBits ) {
237 $this->
addWhere( $db->bitAnd(
'log_deleted', $titleBits ) .
" != $titleBits" );
239 if ( !is_null( $user ) && $userBits ) {
240 $this->
addWhere( $db->bitAnd(
'log_deleted', $userBits ) .
" != $userBits" );
248 if ( $params[
'tag'] ===
null ) {
255 foreach (
$res as $row ) {
256 if ( ++$count > $limit ) {
264 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
270 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'item' );
281 if ( $this->fld_ids ) {
282 $vals[
'logid'] = (int)$row->log_id;
285 if ( $this->fld_title || $this->fld_parsedcomment ) {
289 if ( $this->fld_title || $this->fld_ids || $this->fld_details && $row->log_params !==
'' ) {
291 $vals[
'actionhidden'] =
true;
295 if ( $this->fld_title ) {
298 if ( $this->fld_ids ) {
299 $vals[
'pageid'] = (int)$row->page_id;
300 $vals[
'logpage'] = (
int)$row->log_page;
302 if ( $this->fld_details ) {
308 if ( $this->fld_type ) {
309 $vals[
'type'] = $row->log_type;
310 $vals[
'action'] = $row->log_action;
313 if ( $this->fld_user || $this->fld_userid ) {
315 $vals[
'userhidden'] =
true;
319 if ( $this->fld_user ) {
320 $vals[
'user'] = $row->user_name ?? $row->log_user_text;
322 if ( $this->fld_userid ) {
323 $vals[
'userid'] = (int)$row->log_user;
326 if ( !$row->log_user ) {
327 $vals[
'anon'] =
true;
331 if ( $this->fld_timestamp ) {
332 $vals[
'timestamp'] =
wfTimestamp( TS_ISO_8601, $row->log_timestamp );
335 if ( $this->fld_comment || $this->fld_parsedcomment ) {
337 $vals[
'commenthidden'] =
true;
341 $comment = $this->commentStore->getComment(
'log_comment', $row )->text;
342 if ( $this->fld_comment ) {
343 $vals[
'comment'] = $comment;
346 if ( $this->fld_parsedcomment ) {
352 if ( $this->fld_tags ) {
353 if ( $row->ts_tags ) {
354 $tags = explode(
',', $row->ts_tags );
356 $vals[
'tags'] = $tags;
363 $vals[
'suppressed'] =
true;
374 return array_keys( array_merge(
375 $config->get(
'LogActions' ),
376 $config->get(
'LogActionsHandlers' )
384 if ( !is_null( $params[
'prop'] ) && in_array(
'parsedcomment', $params[
'prop'] ) ) {
386 return 'anon-public-user-private';
392 return 'anon-public-user-private';
465 if ( $config->get(
'MiserMode' ) ) {
474 'action=query&list=logevents'
475 =>
'apihelp-query+logevents-example-simple',
480 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Logevents';
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
addFields( $value)
Add a set of fields to select to the internal array.
static validTypes()
Get the list of valid log types.
This is the main query class.
getExamplesMessages()
Returns usage examples for this module.
const META_TYPE
Key for the 'type' metadata item.
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.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
__construct(ApiQuery $query, $moduleName)
static newMigration()
Static constructor.
Query action to List the log events, with optional filtering by various parameters.
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
static newFromRow( $row)
Constructs new LogEntry from database result row.
getAllowedParams( $flags=0)
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'.
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,...
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
const PARAM_EXTRA_NAMESPACES
(int[]) When PARAM_TYPE is 'namespace', include these as additional possible values.
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.
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.
const GET_VALUES_FOR_HELP
getAllowedParams() flag: When set, the result could take longer to generate, but should be more thoro...
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
static getExcludeClause( $db, $audience='public', User $user=null)
SQL clause to skip forbidden log types for this user.
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( [ $field => $value ] )
requireMaxOneParameter( $params, $required)
Die if 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...
const LIMIT_BIG2
Fast query, apihighlimits limit.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
static userCan( $row, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
static isDeleted( $row, $field)
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.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
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...
userCanSeeRevDel()
Check whether the current user has permission to view revision-deleted fields.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.