29use Wikimedia\Assert\Assert;
129 $this->relations = $relations;
149 $this->target = Title::newFromLinkTarget( $target );
197 wfDebug(
'Overwriting existing ManualLogEntry tags' );
210 if (
$tags ===
null ) {
214 if ( is_string(
$tags ) ) {
217 Assert::parameterElementType(
'string',
$tags,
'tags' );
218 $this->tags = array_unique( array_merge( $this->tags,
$tags ) );
231 $this->isPatrollable = (bool)$patrollable;
264 if ( $this->timestamp ===
null ) {
277 $params[
'associated_rev_id'] =
$revId;
282 'log_type' => $this->
getType(),
284 'log_timestamp' => $dbw->timestamp( $this->
getTimestamp() ),
285 'log_namespace' => $this->
getTarget()->getNamespace(),
286 'log_title' => $this->
getTarget()->getDBkey(),
287 'log_page' => $this->
getTarget()->getArticleID(),
290 if ( isset( $this->deleted ) ) {
291 $data[
'log_deleted'] = $this->deleted;
293 $data += CommentStore::getStore()->insert( $dbw,
'log_comment',
$comment );
294 $data += ActorMigration::newMigration()
295 ->getInsertValues( $dbw,
'log_user', $this->
getPerformer() );
297 $dbw->insert(
'logging', $data, __METHOD__ );
298 $this->
id = $dbw->insertId();
302 if ( !strlen( $tag ) ) {
303 throw new MWException(
"Got empty log search tag." );
306 if ( !is_array( $values ) ) {
307 $values = [ $values ];
310 foreach ( $values as $value ) {
313 'ls_value' => $value,
314 'ls_log_id' => $this->id
318 if ( count( $rows ) ) {
319 $dbw->insert(
'log_search', $rows, __METHOD__, [
'IGNORE' ] );
334 $context = RequestContext::newExtraneousContext( $this->
getTarget() );
335 $formatter->setContext( $context );
340 if ( $user->isAnon() ) {
343 if ( IPUtils::isIPAddress( $user->getName() ) ) {
344 $ip = $user->getName();
348 return RecentChange::newLogEntry(
352 $formatter->getPlainActionText(),
360 $formatter->getIRCActionComment(),
361 $this->getAssociatedRevId(),
362 $this->getIsPatrollable()
372 public function publish( $newId, $to =
'rcandudp' ) {
376 \MediaWiki\Logger\LoggerFactory::getInstance(
'logging' )->warning(
377 'newId and/or revId must be set when calling ManualLogEntry::publish()',
383 'exception' =>
new RuntimeException()
389 DeferredUpdates::addCallableUpdate(
390 function () use ( $newId, $to, $canAddTags ) {
392 if ( !$log->isRestricted() ) {
393 Hooks::runner()->onManualLogEntryBeforePublish( $this );
396 if ( $to ===
'rc' || $to ===
'rcandudp' ) {
398 $rc->addTags( $this->
getTags() );
399 $rc->save( $rc::SEND_NONE );
402 if (
$tags && $canAddTags ) {
408 $newId > 0 ? $newId : null
413 if ( $to ===
'udp' || $to ===
'rcandudp' ) {
414 $rc->notifyRCFeeds();
418 DeferredUpdates::POSTSEND,
434 return $this->subtype;
441 return $this->parameters;
448 return $this->performer;
455 return $this->target;
471 return $this->comment;
497 return $this->isPatrollable;
505 return $this->legacy;
512 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.
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.
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.
bool $isPatrollable
Can this log entry be patrolled?
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,...
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)
Stable to call.
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.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromIdentity(UserIdentity $identity)
Returns a User object corresponding to the given UserIdentity.