30use Wikimedia\Assert\Assert;
123 $this->relations = $relations;
133 $this->performer = User::newFromIdentity( $performer );
143 $this->target = Title::newFromLinkTarget( $target );
191 wfDebug(
'Overwriting existing ManualLogEntry tags' );
204 if (
$tags ===
null ) {
208 if ( is_string(
$tags ) ) {
211 Assert::parameterElementType(
'string',
$tags,
'tags' );
212 $this->tags = array_unique( array_merge( $this->tags,
$tags ) );
225 $this->isPatrollable = (bool)$patrollable;
258 if ( $this->timestamp ===
null ) {
271 $params[
'associated_rev_id'] =
$revId;
276 'log_type' => $this->
getType(),
278 'log_timestamp' => $dbw->timestamp( $this->
getTimestamp() ),
279 'log_namespace' => $this->
getTarget()->getNamespace(),
280 'log_title' => $this->
getTarget()->getDBkey(),
281 'log_page' => $this->
getTarget()->getArticleID(),
284 if ( isset( $this->deleted ) ) {
285 $data[
'log_deleted'] = $this->deleted;
287 $data += CommentStore::getStore()->insert( $dbw,
'log_comment',
$comment );
288 $data += ActorMigration::newMigration()
289 ->getInsertValues( $dbw,
'log_user', $this->
getPerformer() );
291 $dbw->insert(
'logging', $data, __METHOD__ );
292 $this->
id = $dbw->insertId();
296 if ( !strlen( $tag ) ) {
297 throw new MWException(
"Got empty log search tag." );
300 if ( !is_array( $values ) ) {
301 $values = [ $values ];
304 foreach ( $values as $value ) {
307 'ls_value' => $value,
308 'ls_log_id' => $this->id
312 if ( count( $rows ) ) {
313 $dbw->insert(
'log_search', $rows, __METHOD__, [
'IGNORE' ] );
331 $logpage = SpecialPage::getTitleFor(
'Log', $this->
getType() );
334 if ( $user->isAnon() ) {
337 if ( IP::isIPAddress( $user->getName() ) ) {
338 $ip = $user->getName();
342 return RecentChange::newLogEntry(
346 $formatter->getPlainActionText(),
354 $formatter->getIRCActionComment(),
355 $this->getAssociatedRevId(),
356 $this->getIsPatrollable()
366 public function publish( $newId, $to =
'rcandudp' ) {
370 \MediaWiki\Logger\LoggerFactory::getInstance(
'logging' )->warning(
371 'newId and/or revId must be set when calling ManualLogEntry::publish()',
377 'exception' =>
new RuntimeException()
383 DeferredUpdates::addCallableUpdate(
384 function () use ( $newId, $to, $canAddTags ) {
386 if ( !$log->isRestricted() ) {
387 Hooks::runWithoutAbort(
'ManualLogEntryBeforePublish', [ $this ] );
390 if ( $to ===
'rc' || $to ===
'rcandudp' ) {
392 $rc->addTags( $this->
getTags() );
393 $rc->save( $rc::SEND_NONE );
396 if (
$tags && $canAddTags ) {
402 $newId > 0 ? $newId : null
407 if ( $to ===
'udp' || $to ===
'rcandudp' ) {
408 $rc->notifyRCFeeds();
412 DeferredUpdates::POSTSEND,
422 return $this->subtype;
426 return $this->parameters;
433 return $this->performer;
440 return $this->target;
450 return $this->comment;
476 return $this->isPatrollable;
484 return $this->legacy;
488 return (
int)$this->deleted;
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Extends the LogEntry Interface with some basic functionality.
static makeParamBlob( $params)
Create a blob from a parameter array.
Class to simplify the use of log pages.
Class for creating new log entries and inserting them into the database.
getDeleted()
Get the access restriction.
getIsPatrollable()
Whether this log entry is patrollable.
setDeleted( $deleted)
Set the 'deleted' flag.
string $subtype
Sub type of log entry.
addTags( $tags)
Add change tags for the log entry.
int $id
ID of the log entry.
string[] $tags
Change tags add to the log entry.
string $type
Type of log entry.
setAssociatedRevId( $revId)
Set an associated revision id.
insert(IDatabase $dbw=null)
Insert the entry into the logging table.
string $comment
Comment for the log entry.
setTimestamp( $timestamp)
Set the timestamp of when the logged action took place.
array $parameters
Parameters for log entry.
getTimestamp()
Get the timestamp when the action was executed.
int $revId
A rev id associated to the log entry.
setComment( $comment)
Set a comment associated with the action being logged.
setParameters( $parameters)
Set extra log parameters.
getComment()
Get the user provided comment.
bool $isPatrollable
Can this log entry be patrolled?
getType()
The main log type.
Title $target
Target title for the log entry.
int $deleted
Deletion state of the log entry.
setLegacy( $legacy)
Set the 'legacy' flag.
setIsPatrollable( $patrollable)
Set whether this log entry should be made patrollable This shouldn't depend on config,...
getParameters()
Get the extra parameters stored for this message.
bool $legacy
Whether this is a legacy log entry.
string $timestamp
Timestamp of creation of the log entry.
setPerformer(UserIdentity $performer)
Set the user that performed the action being logged.
getRecentChange( $newId=0)
Get a RecentChanges object for the log entry.
User $performer
Performer of the action for the log entry.
setRelations(array $relations)
Declare arbitrary tag/value relations to this log entry.
__construct( $type, $subtype)
setTags( $tags)
Set change tags for the log entry.
setTarget(LinkTarget $target)
Set the title of the object changed.
publish( $newId, $to='rcandudp')
Publish the log entry.
getSubtype()
The log subtype.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...