MediaWiki master
MediaWiki\Logging\ManualLogEntry Class Reference

Class for creating new log entries and inserting them into the database. More...

Inherits MediaWiki\Logging\LogEntryBase, and MediaWiki\ChangeTags\Taggable.

Collaboration diagram for MediaWiki\Logging\ManualLogEntry:

Public Member Functions

 __construct ( $type, $subtype)
 
 addParameter ( $name, $value)
 Add a parameter to the list already set.
 
 addTags ( $tags)
 Add change tags for the log entry.
 
 getAssociatedRevId ()
 
 getComment ()
 
 getDeleted ()
 
 getIsPatrollable ()
 Whether this log entry is patrollable.
 
 getParameters ()
 
 getPerformerIdentity ()
 
 getRecentChange ( $newId=0)
 Get a RecentChanges object for the log entry.
 
 getSubtype ()
 
 getTags ()
 
 getTarget ()
 
 getTimestamp ()
 
 getType ()
 
 insert (?IDatabase $dbw=null)
 Insert the entry into the logging table.
 
 isLegacy ()
 
 publish ( $newId, $to='rcandudp')
 Publish the log entry.
 
 setAssociatedRevId ( $revId)
 Set an associated revision id.
 
 setComment (string $comment)
 Set a comment associated with the action being logged.
 
 setDeleted ( $deleted)
 Set the 'deleted' flag.
 
 setForceBotFlag (bool $forceBotFlag)
 Set the bot flag in the recent changes to this value.
 
 setIsPatrollable ( $patrollable)
 Set whether this log entry should be made patrollable This shouldn't depend on config, only on whether there is full support in the software for patrolling this log entry.
 
 setLegacy ( $legacy)
 Set the 'legacy' flag.
 
 setParameters ( $parameters)
 Set extra log parameters.
 
 setPerformer (UserIdentity $performer)
 Set the user that performed the action being logged.
 
 setRelations (array $relations)
 Declare arbitrary tag/value relations to this log entry.
 
 setTarget ( $target)
 Set the title of the object changed.
 
 setTimestamp ( $timestamp)
 Set the timestamp of when the logged action took place.
 
- Public Member Functions inherited from MediaWiki\Logging\LogEntryBase
 getFullType ()
 The full logtype in format maintype/subtype.
 
 isDeleted ( $field)
 

Protected Attributes

string $comment = ''
 Comment for the log entry.
 
int null $deleted
 Deletion state of the log entry.
 
bool null $forceBotFlag = null
 The bot flag in the recent changes will be set to this value.
 
int $id
 ID of the log entry.
 
bool $isPatrollable = false
 Can this log entry be patrolled?
 
bool $legacy = false
 Whether this is a legacy log entry.
 
array $parameters = []
 Parameters for log entry.
 
UserIdentity $performer
 Performer of the action for the log entry.
 
array $relations = []
 
int $revId = 0
 A rev id associated to the log entry.
 
string $subtype
 Sub type of log entry.
 
string[] $tags = []
 Change tags add to the log entry.
 
Title $target
 Target title for the log entry.
 
string $timestamp
 Timestamp of creation of the log entry.
 
string $type
 Type of log entry.
 

Additional Inherited Members

- Static Public Member Functions inherited from MediaWiki\Logging\LogEntryBase
static extractParams ( $blob)
 Extract a parameter array from a blob.
 
static makeParamBlob ( $params)
 Create a blob from a parameter array.
 

Detailed Description

Class for creating new log entries and inserting them into the database.

Stability: newable
Note
marked as newable in 1.35 for lack of a better alternative, but should be changed to use the builder pattern or the command pattern.
Since
1.19
See also
https://www.mediawiki.org/wiki/Manual:Logging_to_Special:Log

Definition at line 55 of file ManualLogEntry.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Logging\ManualLogEntry::__construct ( $type,
$subtype )
Stability: stable
to call
Since
1.19
Parameters
string$typeLog type. Should match $wgLogTypes.
string$subtypeLog subtype (action). Should match $wgLogActions or (together with $type) $wgLogActionsHandlers.
Note

Definition at line 109 of file ManualLogEntry.php.

References MediaWiki\Logging\ManualLogEntry\$subtype, and MediaWiki\Logging\ManualLogEntry\$type.

Member Function Documentation

◆ addParameter()

MediaWiki\Logging\ManualLogEntry::addParameter ( $name,
$value )

Add a parameter to the list already set.

See also
setParameters
Since
1.44
Parameters
string$name
mixed$value

Definition at line 169 of file ManualLogEntry.php.

◆ addTags()

MediaWiki\Logging\ManualLogEntry::addTags ( $tags)

Add change tags for the log entry.

Since
1.33
Parameters
string | string[] | null$tagsTags to apply

Implements MediaWiki\ChangeTags\Taggable.

Definition at line 252 of file ManualLogEntry.php.

References MediaWiki\Logging\ManualLogEntry\$tags.

◆ getAssociatedRevId()

MediaWiki\Logging\ManualLogEntry::getAssociatedRevId ( )
Since
1.27
Returns
int

Definition at line 531 of file ManualLogEntry.php.

◆ getComment()

MediaWiki\Logging\ManualLogEntry::getComment ( )
Returns
string

Implements MediaWiki\Logging\LogEntry.

Definition at line 523 of file ManualLogEntry.php.

◆ getDeleted()

MediaWiki\Logging\ManualLogEntry::getDeleted ( )
Returns
int

Implements MediaWiki\Logging\LogEntry.

Definition at line 564 of file ManualLogEntry.php.

◆ getIsPatrollable()

MediaWiki\Logging\ManualLogEntry::getIsPatrollable ( )

Whether this log entry is patrollable.

Since
1.27
Returns
bool

Definition at line 549 of file ManualLogEntry.php.

◆ getParameters()

MediaWiki\Logging\ManualLogEntry::getParameters ( )
Returns
array

Implements MediaWiki\Logging\LogEntry.

Definition at line 496 of file ManualLogEntry.php.

◆ getPerformerIdentity()

MediaWiki\Logging\ManualLogEntry::getPerformerIdentity ( )
Since
1.36
Returns
UserIdentity

Implements MediaWiki\Logging\LogEntry.

Definition at line 500 of file ManualLogEntry.php.

◆ getRecentChange()

MediaWiki\Logging\ManualLogEntry::getRecentChange ( $newId = 0)

Get a RecentChanges object for the log entry.

Parameters
int$newId
Returns
RecentChange
Since
1.23

Definition at line 392 of file ManualLogEntry.php.

References MediaWiki\MediaWikiServices\getInstance(), getTimestamp(), MediaWiki\SpecialPage\SpecialPage\getTitleFor(), and MediaWiki\Logging\LogEntryBase\makeParamBlob().

◆ getSubtype()

MediaWiki\Logging\ManualLogEntry::getSubtype ( )
Returns
string

Implements MediaWiki\Logging\LogEntry.

Definition at line 489 of file ManualLogEntry.php.

◆ getTags()

MediaWiki\Logging\ManualLogEntry::getTags ( )
Since
1.27
Returns
string[]

Definition at line 539 of file ManualLogEntry.php.

◆ getTarget()

MediaWiki\Logging\ManualLogEntry::getTarget ( )
Returns
Title

Implements MediaWiki\Logging\LogEntry.

Definition at line 507 of file ManualLogEntry.php.

◆ getTimestamp()

MediaWiki\Logging\ManualLogEntry::getTimestamp ( )
Returns
string|false TS_MW timestamp, a string with 14 digits

Implements MediaWiki\Logging\LogEntry.

Definition at line 514 of file ManualLogEntry.php.

References wfTimestamp(), and wfTimestampNow().

◆ getType()

MediaWiki\Logging\ManualLogEntry::getType ( )
Returns
string

Implements MediaWiki\Logging\LogEntry.

Definition at line 482 of file ManualLogEntry.php.

◆ insert()

MediaWiki\Logging\ManualLogEntry::insert ( ?IDatabase $dbw = null)

Insert the entry into the logging table.

Parameters
IDatabase | null$dbw
Returns
int ID of the log entry

Definition at line 313 of file ManualLogEntry.php.

References MediaWiki\MediaWikiServices\getInstance(), getTimestamp(), MediaWiki\Logging\LogEntryBase\makeParamBlob(), and wfTimestampNow().

◆ isLegacy()

MediaWiki\Logging\ManualLogEntry::isLegacy ( )
Since
1.25
Returns
bool

Reimplemented from MediaWiki\Logging\LogEntryBase.

Definition at line 557 of file ManualLogEntry.php.

◆ publish()

MediaWiki\Logging\ManualLogEntry::publish ( $newId,
$to = 'rcandudp' )

Publish the log entry.

Parameters
int$newIdId of the log entry.
string$toOne of: rcandudp (default), rc, udp

Definition at line 424 of file ManualLogEntry.php.

References MediaWiki\MediaWikiServices\getInstance().

◆ setAssociatedRevId()

MediaWiki\Logging\ManualLogEntry::setAssociatedRevId ( $revId)

Set an associated revision id.

For example, the ID of the revision that was inserted to mark a page move or protection, file upload, etc.

Since
1.27
Parameters
int$revId

Definition at line 242 of file ManualLogEntry.php.

References MediaWiki\Logging\ManualLogEntry\$revId.

◆ setComment()

MediaWiki\Logging\ManualLogEntry::setComment ( string $comment)

Set a comment associated with the action being logged.

Since
1.19
Parameters
string$comment

Definition at line 229 of file ManualLogEntry.php.

References MediaWiki\Logging\ManualLogEntry\$comment.

◆ setDeleted()

MediaWiki\Logging\ManualLogEntry::setDeleted ( $deleted)

Set the 'deleted' flag.

Since
1.19
Parameters
int$deletedOne of LogPage::DELETED_* bitfield constants

Definition at line 293 of file ManualLogEntry.php.

References MediaWiki\Logging\ManualLogEntry\$deleted.

◆ setForceBotFlag()

MediaWiki\Logging\ManualLogEntry::setForceBotFlag ( bool $forceBotFlag)

Set the bot flag in the recent changes to this value.

Since
1.40
Parameters
bool$forceBotFlag

Definition at line 303 of file ManualLogEntry.php.

◆ setIsPatrollable()

MediaWiki\Logging\ManualLogEntry::setIsPatrollable ( $patrollable)

Set whether this log entry should be made patrollable This shouldn't depend on config, only on whether there is full support in the software for patrolling this log entry.

False by default

Since
1.27
Parameters
bool$patrollable

Definition at line 273 of file ManualLogEntry.php.

◆ setLegacy()

MediaWiki\Logging\ManualLogEntry::setLegacy ( $legacy)

Set the 'legacy' flag.

Since
1.25
Parameters
bool$legacy

Definition at line 283 of file ManualLogEntry.php.

References MediaWiki\Logging\ManualLogEntry\$legacy.

◆ setParameters()

MediaWiki\Logging\ManualLogEntry::setParameters ( $parameters)

Set extra log parameters.

Takes an array in a parameter name => parameter value format. The array will be converted to string via serialize() and stored in the log_params database field. (If you want to store parameters in such a way that they can be targeted by DB queries, use setRelations() instead.)

You can pass these parameters to the log action message by prefixing the keys with a number and optional type, using colons to separate the fields. The numbering should start with number 4 (matching the $4 message parameter), as the first three parameters are hardcoded for every message ($1 is a link to the username and user talk page of the performing user, $2 is just the username (for determining gender), $3 is a link to the target page).

If you want to store stuff that should not be available in messages, don't prefix the array key with a number and don't use the colons. (Note that such parameters will still be publicly viewable via the API.)

Example: $entry->setParameters( [ // store and use in messages as $4 '4::color' => 'blue', // store as is, use in messages as $5 with Message::numParam() '5:number:count' => 3000, // store but do not use in messages 'animal' => 'dog' ] );

Typically, these parameters will be used in the logentry-<type>-<subtype> message, but custom formatters, declared via $wgLogActionsHandlers, can override that.

Since
1.19
Parameters
array$parametersAssociative array
See also
LogFormatter::formatParameterValue() for valid parameter types and their meanings.
self::setRelations() for storing parameters in a way that can be searched.
LogFormatter::getMessageKey() for determining which message these parameters will be used in.

Definition at line 156 of file ManualLogEntry.php.

References MediaWiki\Logging\ManualLogEntry\$parameters.

◆ setPerformer()

MediaWiki\Logging\ManualLogEntry::setPerformer ( UserIdentity $performer)

Set the user that performed the action being logged.

Since
1.19
Parameters
UserIdentity$performer

Definition at line 192 of file ManualLogEntry.php.

References MediaWiki\Logging\ManualLogEntry\$performer.

◆ setRelations()

MediaWiki\Logging\ManualLogEntry::setRelations ( array $relations)

Declare arbitrary tag/value relations to this log entry.

These will be stored in the log_search table and can be used to filter log entries later on.

Parameters
array$relationsMap of (tag => (list of values|value)); values must be string. When an array of values is given, a separate DB row will be created for each value.
Since
1.22

Definition at line 182 of file ManualLogEntry.php.

References MediaWiki\Logging\ManualLogEntry\$relations.

◆ setTarget()

MediaWiki\Logging\ManualLogEntry::setTarget ( $target)

Set the title of the object changed.

Parameters
LinkTarget | PageReference$targetcalling with LinkTarget is deprecated since 1.37
Since
1.19

Definition at line 203 of file ManualLogEntry.php.

References MediaWiki\Logging\ManualLogEntry\$target.

◆ setTimestamp()

MediaWiki\Logging\ManualLogEntry::setTimestamp ( $timestamp)

Set the timestamp of when the logged action took place.

Since
1.19
Parameters
string$timestampCan be in any format accepted by ConvertibleTimestamp

Definition at line 219 of file ManualLogEntry.php.

References MediaWiki\Logging\ManualLogEntry\$timestamp.

Member Data Documentation

◆ $comment

string MediaWiki\Logging\ManualLogEntry::$comment = ''
protected

Comment for the log entry.

Definition at line 78 of file ManualLogEntry.php.

Referenced by MediaWiki\Logging\ManualLogEntry\setComment().

◆ $deleted

int null MediaWiki\Logging\ManualLogEntry::$deleted
protected

Deletion state of the log entry.

Definition at line 87 of file ManualLogEntry.php.

Referenced by MediaWiki\Logging\ManualLogEntry\setDeleted().

◆ $forceBotFlag

bool null MediaWiki\Logging\ManualLogEntry::$forceBotFlag = null
protected

The bot flag in the recent changes will be set to this value.

Definition at line 99 of file ManualLogEntry.php.

◆ $id

int MediaWiki\Logging\ManualLogEntry::$id
protected

ID of the log entry.

Definition at line 90 of file ManualLogEntry.php.

◆ $isPatrollable

bool MediaWiki\Logging\ManualLogEntry::$isPatrollable = false
protected

Can this log entry be patrolled?

Definition at line 93 of file ManualLogEntry.php.

◆ $legacy

bool MediaWiki\Logging\ManualLogEntry::$legacy = false
protected

Whether this is a legacy log entry.

Definition at line 96 of file ManualLogEntry.php.

Referenced by MediaWiki\Logging\ManualLogEntry\setLegacy().

◆ $parameters

array MediaWiki\Logging\ManualLogEntry::$parameters = []
protected

Parameters for log entry.

Definition at line 63 of file ManualLogEntry.php.

Referenced by MediaWiki\Logging\ManualLogEntry\setParameters().

◆ $performer

UserIdentity MediaWiki\Logging\ManualLogEntry::$performer
protected

Performer of the action for the log entry.

Definition at line 69 of file ManualLogEntry.php.

Referenced by MediaWiki\Logging\ManualLogEntry\setPerformer().

◆ $relations

array MediaWiki\Logging\ManualLogEntry::$relations = []
protected

Definition at line 66 of file ManualLogEntry.php.

Referenced by MediaWiki\Logging\ManualLogEntry\setRelations().

◆ $revId

int MediaWiki\Logging\ManualLogEntry::$revId = 0
protected

A rev id associated to the log entry.

Definition at line 81 of file ManualLogEntry.php.

Referenced by MediaWiki\Logging\ManualLogEntry\setAssociatedRevId().

◆ $subtype

string MediaWiki\Logging\ManualLogEntry::$subtype
protected

Sub type of log entry.

Definition at line 60 of file ManualLogEntry.php.

Referenced by MediaWiki\Logging\ManualLogEntry\__construct().

◆ $tags

string [] MediaWiki\Logging\ManualLogEntry::$tags = []
protected

Change tags add to the log entry.

Definition at line 84 of file ManualLogEntry.php.

Referenced by MediaWiki\Logging\ManualLogEntry\addTags().

◆ $target

Title MediaWiki\Logging\ManualLogEntry::$target
protected

Target title for the log entry.

Definition at line 72 of file ManualLogEntry.php.

Referenced by MediaWiki\Logging\ManualLogEntry\setTarget().

◆ $timestamp

string MediaWiki\Logging\ManualLogEntry::$timestamp
protected

Timestamp of creation of the log entry.

Definition at line 75 of file ManualLogEntry.php.

Referenced by MediaWiki\Logging\ManualLogEntry\setTimestamp().

◆ $type

string MediaWiki\Logging\ManualLogEntry::$type
protected

Type of log entry.

Definition at line 57 of file ManualLogEntry.php.

Referenced by MediaWiki\Logging\ManualLogEntry\__construct().


The documentation for this class was generated from the following file: