52 parent::__construct( $query, $moduleName,
'le' );
67 $prop = array_fill_keys( $params[
'prop'],
true );
69 $this->fld_ids = isset( $prop[
'ids'] );
70 $this->fld_title = isset( $prop[
'title'] );
71 $this->fld_type = isset( $prop[
'type'] );
72 $this->fld_user = isset( $prop[
'user'] );
73 $this->fld_userid = isset( $prop[
'userid'] );
74 $this->fld_timestamp = isset( $prop[
'timestamp'] );
75 $this->fld_comment = isset( $prop[
'comment'] );
76 $this->fld_parsedcomment = isset( $prop[
'parsedcomment'] );
77 $this->fld_details = isset( $prop[
'details'] );
78 $this->fld_tags = isset( $prop[
'tags'] );
80 $hideLogs = LogEventsList::getExcludeClause( $db,
'user', $this->
getUser() );
81 if ( $hideLogs !==
false ) {
85 $this->
addTables( [
'logging',
'actor',
'page' ] );
87 'actor' => [
'JOIN',
'actor_id=log_actor' ],
88 'page' => [
'LEFT JOIN',
89 [
'log_namespace=page_namespace',
90 'log_title=page_title' ] ] ] );
105 $this->
addFieldsIf( [
'actor_name',
'actor_user' ], $this->fld_user );
106 $this->
addFieldsIf(
'actor_user', $this->fld_userid );
108 [
'log_namespace',
'log_title' ],
109 $this->fld_title || $this->fld_parsedcomment
111 $this->
addFieldsIf(
'log_params', $this->fld_details );
113 if ( $this->fld_comment || $this->fld_parsedcomment ) {
114 $commentQuery = $this->commentStore->getJoin(
'log_comment' );
115 $this->
addTables( $commentQuery[
'tables'] );
116 $this->
addFields( $commentQuery[
'fields'] );
120 if ( $this->fld_tags ) {
124 if ( $params[
'tag'] !==
null ) {
127 [
'log_id=ct_log_id' ] ] ] );
129 $this->
addWhereFld(
'ct_tag_id', $this->changeTagDefStore->getId( $params[
'tag'] ) );
136 if ( $params[
'action'] !==
null ) {
139 $logAction = $params[
'action'];
140 if ( strpos( $logAction,
'/' ) ===
false ) {
145 list(
$type, $action ) = explode(
'/', $logAction, 2 );
146 $valid = isset( $logActions[$logAction] ) || isset( $logActions[
$type .
'/*'] );
152 [
'apierror-unrecognizedvalue', $encParamName,
wfEscapeWikiText( $logAction ) ],
153 "unknown_$encParamName"
159 } elseif ( $params[
'type'] !==
null ) {
170 $this->
addWhereRange(
'log_id', $params[
'dir'],
null,
null );
172 if ( $params[
'continue'] !==
null ) {
173 $cont = explode(
'|', $params[
'continue'] );
175 $op = ( $params[
'dir'] ===
'newer' ?
'>' :
'<' );
176 $continueTimestamp = $db->addQuotes( $db->timestamp( $cont[0] ) );
177 $continueId = (int)$cont[1];
179 $this->
addWhere(
"log_timestamp $op $continueTimestamp OR " .
180 "(log_timestamp = $continueTimestamp AND " .
181 "log_id $op= $continueId)"
185 $limit = $params[
'limit'];
188 $user = $params[
'user'];
189 if ( $user !==
null ) {
193 $title = $params[
'title'];
195 $titleObj = Title::newFromText(
$title );
196 if ( $titleObj ===
null ) {
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 ( $prefix !==
null ) {
210 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
214 $title = Title::newFromText( $prefix );
219 $this->
addWhere(
'log_title ' . $db->buildLike(
$title->getDBkey(), $db->anyString() ) );
223 if ( $params[
'namespace'] !==
null ||
$title !==
null || $user !==
null ) {
224 if ( !$this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
227 } elseif ( !$this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
234 if ( ( $params[
'namespace'] !==
null ||
$title !==
null ) && $titleBits ) {
235 $this->
addWhere( $db->bitAnd(
'log_deleted', $titleBits ) .
" != $titleBits" );
237 if ( $user !==
null && $userBits ) {
238 $this->
addWhere( $db->bitAnd(
'log_deleted', $userBits ) .
" != $userBits" );
247 if ( $params[
'tag'] ===
null && $user ===
null ) {
252 'MAX_EXECUTION_TIME',
253 $this->
getConfig()->
get(
'MaxExecutionTimeForExpensiveQueries' )
259 if ( $this->fld_title ) {
264 foreach (
$res as $row ) {
265 if ( ++$count > $limit ) {
273 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
279 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'item' );
283 $logEntry = DatabaseLogEntry::newFromRow( $row );
285 ApiResult::META_TYPE =>
'assoc',
290 if ( $this->fld_ids ) {
291 $vals[
'logid'] = (int)$row->log_id;
294 if ( $this->fld_title || $this->fld_parsedcomment ) {
295 $title = Title::makeTitle( $row->log_namespace, $row->log_title );
298 if ( $this->fld_title || $this->fld_ids || $this->fld_details && $row->log_params !==
'' ) {
300 $vals[
'actionhidden'] =
true;
304 if ( $this->fld_title ) {
307 if ( $this->fld_ids ) {
308 $vals[
'pageid'] = (int)$row->page_id;
309 $vals[
'logpage'] = (int)$row->log_page;
311 if ( $this->fld_details ) {
317 if ( $this->fld_type ) {
318 $vals[
'type'] = $row->log_type;
319 $vals[
'action'] = $row->log_action;
322 if ( $this->fld_user || $this->fld_userid ) {
324 $vals[
'userhidden'] =
true;
328 if ( $this->fld_user ) {
329 $vals[
'user'] = $row->actor_name;
331 if ( $this->fld_userid ) {
332 $vals[
'userid'] = (int)$row->actor_user;
335 if ( !$row->actor_user ) {
336 $vals[
'anon'] =
true;
340 if ( $this->fld_timestamp ) {
341 $vals[
'timestamp'] =
wfTimestamp( TS_ISO_8601, $row->log_timestamp );
344 if ( $this->fld_comment || $this->fld_parsedcomment ) {
346 $vals[
'commenthidden'] =
true;
350 $comment = $this->commentStore->getComment(
'log_comment', $row )->text;
351 if ( $this->fld_comment ) {
352 $vals[
'comment'] = $comment;
355 if ( $this->fld_parsedcomment ) {
361 if ( $this->fld_tags ) {
362 if ( $row->ts_tags ) {
363 $tags = explode(
',', $row->ts_tags );
364 ApiResult::setIndexedTagName( $tags,
'tag' );
365 $vals[
'tags'] = $tags;
372 $vals[
'suppressed'] =
true;
383 return array_keys( array_merge(
384 $config->get(
'LogActions' ),
385 $config->get(
'LogActionsHandlers' )
393 if ( $params[
'prop'] !==
null && in_array(
'parsedcomment', $params[
'prop'] ) ) {
395 return 'anon-public-user-private';
396 } elseif ( LogEventsList::getExcludeClause( $this->
getDB(),
'user', $this->
getUser() )
397 === LogEventsList::getExcludeClause( $this->
getDB(),
'public' )
401 return 'anon-public-user-private';
454 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
475 if ( $config->get(
'MiserMode' ) ) {
484 'action=query&list=logevents'
485 =>
'apihelp-query+logevents-example-simple',
490 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Logevents';
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
const LIMIT_BIG1
Fast query, standard limit.
requireMaxOneParameter( $params,... $required)
Die if more than one of a certain set of parameters is set and not false.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_EXTRA_NAMESPACES
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const GET_VALUES_FOR_HELP
getAllowedParams() flag: When set, the result could take longer to generate, but should be more thoro...
const LIMIT_BIG2
Fast query, apihighlimits limit.
getModuleName()
Get the name of the module being executed by this instance.
This is a base class for all Query modules.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
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.
addFields( $value)
Add a set of fields to select to the internal array.
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.
addTimestampWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
getDB()
Get the Query database connection (read-only)
executeGenderCacheFromResultWrapper(IResultWrapper $res, $fname=__METHOD__, $fieldPrefix='page')
Preprocess the result set to fill the GenderCache with the necessary information before using self::a...
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
addWhereFld( $field, $value)
Equivalent to addWhere( [ $field => $value ] )
addWhere( $value)
Add a set of WHERE clauses to the internal array.
userCanSeeRevDel()
Check whether the current user has permission to view revision-deleted fields.
Query action to List the log events, with optional filtering by various parameters.
CommentStore $commentStore
getExamplesMessages()
Returns usage examples for this module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
__construct(ApiQuery $query, $moduleName, CommentStore $commentStore, NameTableStore $changeTagDefStore)
getAllowedParams( $flags=0)
NameTableStore $changeTagDefStore
getCacheMode( $params)
Get the cache mode for the data generated by this module.
getHelpUrls()
Return links to more detailed help pages about the module.
This is the main query class.
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...
static validTypes()
Get the list of valid log types.