33 parent::__construct(
$query, $moduleName,
'le' );
44 $this->commentStore = CommentStore::getStore();
47 $prop = array_flip(
$params[
'prop'] );
49 $this->fld_ids = isset( $prop[
'ids'] );
50 $this->fld_title = isset( $prop[
'title'] );
51 $this->fld_type = isset( $prop[
'type'] );
52 $this->fld_user = isset( $prop[
'user'] );
53 $this->fld_userid = isset( $prop[
'userid'] );
54 $this->fld_timestamp = isset( $prop[
'timestamp'] );
55 $this->fld_comment = isset( $prop[
'comment'] );
56 $this->fld_parsedcomment = isset( $prop[
'parsedcomment'] );
57 $this->fld_details = isset( $prop[
'details'] );
58 $this->fld_tags = isset( $prop[
'tags'] );
61 if ( $hideLogs !==
false ) {
65 $actorMigration = ActorMigration::newMigration();
66 $actorQuery = $actorMigration->getJoin(
'log_user' );
68 $this->
addTables( $actorQuery[
'tables'] );
72 'user' => [
'LEFT JOIN',
73 'user_id=' . $actorQuery[
'fields'][
'log_user'] ],
74 'page' => [
'LEFT JOIN',
75 [
'log_namespace=page_namespace',
76 'log_title=page_title' ] ] ] );
91 $this->
addFieldsIf( $actorQuery[
'fields'] + [
'user_name' ], $this->fld_user );
92 $this->
addFieldsIf( $actorQuery[
'fields'], $this->fld_userid );
94 [
'log_namespace',
'log_title' ],
95 $this->fld_title || $this->fld_parsedcomment
97 $this->
addFieldsIf(
'log_params', $this->fld_details );
99 if ( $this->fld_comment || $this->fld_parsedcomment ) {
100 $commentQuery = $this->commentStore->getJoin(
'log_comment' );
101 $this->
addTables( $commentQuery[
'tables'] );
102 $this->
addFields( $commentQuery[
'fields'] );
106 if ( $this->fld_tags ) {
108 $this->
addJoinConds( [
'tag_summary' => [
'LEFT JOIN',
'log_id=ts_log_id' ] ] );
112 if ( !is_null(
$params[
'tag'] ) ) {
115 [
'log_id=ct_log_id' ] ] ] );
119 if ( !is_null(
$params[
'action'] ) ) {
122 $logAction =
$params[
'action'];
123 if ( strpos( $logAction,
'/' ) ===
false ) {
128 list(
$type, $action ) = explode(
'/', $logAction, 2 );
129 $valid = isset( $logActions[$logAction] ) || isset( $logActions[
$type .
'/*'] );
135 [
'apierror-unrecognizedvalue', $encParamName,
wfEscapeWikiText( $logAction ) ],
136 "unknown_$encParamName"
142 } elseif ( !is_null(
$params[
'type'] ) ) {
155 if ( !is_null(
$params[
'continue'] ) ) {
156 $cont = explode(
'|',
$params[
'continue'] );
158 $op = (
$params[
'dir'] ===
'newer' ?
'>' :
'<' );
159 $continueTimestamp = $db->addQuotes( $db->timestamp( $cont[0] ) );
160 $continueId = (int)$cont[1];
162 $this->
addWhere(
"log_timestamp $op $continueTimestamp OR " .
163 "(log_timestamp = $continueTimestamp AND " .
164 "log_id $op= $continueId)"
172 if ( !is_null( $user ) ) {
175 $q = $actorMigration->getWhere(
182 if ( !is_null( $title ) ) {
183 $titleObj = Title::newFromText( $title );
184 if ( is_null( $titleObj ) ) {
187 $this->
addWhereFld(
'log_namespace', $titleObj->getNamespace() );
188 $this->
addWhereFld(
'log_title', $titleObj->getDBkey() );
191 if (
$params[
'namespace'] !==
null ) {
197 if ( !is_null( $prefix ) ) {
198 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
202 $title = Title::newFromText( $prefix );
203 if ( is_null( $title ) ) {
206 $this->
addWhereFld(
'log_namespace', $title->getNamespace() );
207 $this->
addWhere(
'log_title ' . $db->buildLike( $title->getDBkey(), $db->anyString() ) );
211 if (
$params[
'namespace'] !==
null || !is_null( $title ) || !is_null( $user ) ) {
212 if ( !$this->
getUser()->isAllowed(
'deletedhistory' ) ) {
215 } elseif ( !$this->
getUser()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
222 if ( (
$params[
'namespace'] !==
null || !is_null( $title ) ) && $titleBits ) {
223 $this->
addWhere( $db->bitAnd(
'log_deleted', $titleBits ) .
" != $titleBits" );
225 if ( !is_null( $user ) && $userBits ) {
226 $this->
addWhere( $db->bitAnd(
'log_deleted', $userBits ) .
" != $userBits" );
233 foreach (
$res as $row ) {
234 if ( ++$count > $limit ) {
242 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
248 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'item' );
263 $action, $ts, $legacy =
false
268 $entry->setParameters(
$params );
269 $entry->setTimestamp( $ts );
270 $entry->setLegacy( $legacy );
272 $vals[
'params'] = $formatter->formatParametersForApi();
285 if ( $this->fld_ids ) {
286 $vals[
'logid'] = intval( $row->log_id );
289 if ( $this->fld_title || $this->fld_parsedcomment ) {
290 $title = Title::makeTitle( $row->log_namespace, $row->log_title );
293 if ( $this->fld_title || $this->fld_ids || $this->fld_details && $row->log_params !==
'' ) {
295 $vals[
'actionhidden'] =
true;
299 if ( $this->fld_title ) {
302 if ( $this->fld_ids ) {
303 $vals[
'pageid'] = intval( $row->page_id );
304 $vals[
'logpage'] = intval( $row->log_page );
306 if ( $this->fld_details ) {
312 if ( $this->fld_type ) {
313 $vals[
'type'] = $row->log_type;
314 $vals[
'action'] = $row->log_action;
317 if ( $this->fld_user || $this->fld_userid ) {
319 $vals[
'userhidden'] =
true;
323 if ( $this->fld_user ) {
324 $vals[
'user'] = $row->user_name ===
null ? $row->log_user_text : $row->user_name;
326 if ( $this->fld_userid ) {
327 $vals[
'userid'] = intval( $row->log_user );
330 if ( !$row->log_user ) {
331 $vals[
'anon'] =
true;
335 if ( $this->fld_timestamp ) {
336 $vals[
'timestamp'] =
wfTimestamp( TS_ISO_8601, $row->log_timestamp );
339 if ( $this->fld_comment || $this->fld_parsedcomment ) {
341 $vals[
'commenthidden'] =
true;
345 $comment = $this->commentStore->getComment(
'log_comment', $row )->text;
346 if ( $this->fld_comment ) {
347 $vals[
'comment'] = $comment;
350 if ( $this->fld_parsedcomment ) {
356 if ( $this->fld_tags ) {
357 if ( $row->ts_tags ) {
358 $tags = explode(
',', $row->ts_tags );
360 $vals[
'tags'] = $tags;
367 $vals[
'suppressed'] =
true;
378 return array_keys( array_merge(
379 $config->get(
'LogActions' ),
380 $config->get(
'LogActionsHandlers' )
388 if ( !is_null(
$params[
'prop'] ) && in_array(
'parsedcomment',
$params[
'prop'] ) ) {
390 return 'anon-public-user-private';
396 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';
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,...
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
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_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
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_EXTRA_NAMESPACES
(int[]) When PARAM_TYPE is 'namespace', include these as additional possible values.
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.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
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)
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(array($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.
getExamplesMessages()
Returns usage examples for this module.
static addLogParams( $result, &$vals, $params, $type, $action, $ts, $legacy=false)
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getAllowedParams( $flags=0)
__construct(ApiQuery $query, $moduleName)
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.
const META_TYPE
Key for the 'type' metadata item.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
static newFromRow( $row)
Constructs new LogEntry from database result row.
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 getExcludeClause( $db, $audience='public', User $user=null)
SQL clause to skip forbidden log types for this user.
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)
Class for creating log entries manually, to inject them into the database.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
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
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
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 & $ret
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