MediaWiki master
RCDatabaseLogEntry.php
Go to the documentation of this file.
1<?php
26namespace MediaWiki\Logging;
27
28use InvalidArgumentException;
29use LogicException;
35
43
45 public static function newFromId( $id, IReadableDatabase $db ) {
46 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
47 // Make the LSP violation explicit to prevent sneaky failures
48 throw new LogicException( 'Not implemented!' );
49 }
50
52 public static function getSelectQueryData() {
53 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
54 // Make the LSP violation explicit to prevent sneaky failures
55 throw new LogicException( 'Not implemented!' );
56 }
57
59 public function getId() {
60 return $this->row->rc_logid;
61 }
62
64 protected function getRawParameters() {
65 return $this->row->rc_params;
66 }
67
69 public function getAssociatedRevId() {
70 return $this->row->rc_this_oldid;
71 }
72
74 public function getType() {
75 return $this->row->rc_log_type;
76 }
77
79 public function getSubtype() {
80 return $this->row->rc_log_action;
81 }
82
85 if ( !$this->performer ) {
86 $actorStore = MediaWikiServices::getInstance()->getActorStore();
87 $userFactory = MediaWikiServices::getInstance()->getUserFactory();
88 if ( isset( $this->row->rc_actor ) ) {
89 try {
90 $this->performer = $actorStore->newActorFromRowFields(
91 $this->row->rc_user ?? 0,
92 $this->row->rc_user_text,
93 $this->row->rc_actor
94 );
95 } catch ( InvalidArgumentException $e ) {
96 $this->performer = $actorStore->getUnknownActor();
97 LoggerFactory::getInstance( 'logentry' )->warning(
98 'Failed to instantiate RC log entry performer', [
99 'exception' => $e,
100 'log_id' => $this->getId()
101 ]
102 );
103 }
104 } elseif ( isset( $this->row->rc_user ) ) {
105 $this->performer = $userFactory->newFromId( $this->row->rc_user )->getUser();
106 } elseif ( isset( $this->row->rc_user_text ) ) {
107 $user = $userFactory->newFromName( $this->row->rc_user_text );
108 if ( $user ) {
109 $this->performer = $user->getUser();
110 } else {
111 $this->performer = $actorStore->getUnknownActor();
112 LoggerFactory::getInstance( 'logentry' )->warning(
113 'Failed to instantiate RC log entry performer', [
114 'rc_user_text' => $this->row->rc_user_text,
115 'log_id' => $this->getId()
116 ]
117 );
118 }
119 }
120 }
121 return $this->performer;
122 }
123
125 public function getTarget() {
126 $namespace = $this->row->rc_namespace;
127 $page = $this->row->rc_title;
128 return Title::makeTitle( $namespace, $page );
129 }
130
132 public function getTimestamp() {
133 return wfTimestamp( TS_MW, $this->row->rc_timestamp );
134 }
135
137 public function getComment() {
138 $services = MediaWikiServices::getInstance();
139
140 return $services->getCommentStore()
141 // Legacy because the row may have used RecentChange::selectFields()
142 ->getCommentLegacy(
143 $services->getConnectionProvider()->getReplicaDatabase(),
144 'rc_comment',
145 $this->row
146 )->text;
147 }
148
150 public function getDeleted() {
151 return $this->row->rc_deleted;
152 }
153}
154
156class_alias( RCDatabaseLogEntry::class, 'RCDatabaseLogEntry' );
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:82
makeTitle( $linkId)
Convert a link ID to a Title.to override Title
Create PSR-3 logger objects.
A value class to process existing log entries.
A subclass of DatabaseLogEntry for objects constructed from entries in the recentchanges table (rathe...
static getSelectQueryData()
Returns array of information that is needed for querying log entries.Array contains the following key...
getComment()
Get the user provided comment.string
getTarget()
Get the target page of this action.Title
getRawParameters()
Returns whatever is stored in the database field (typically a serialized associative array but very o...
getDeleted()
Get the access restriction.int
static newFromId( $id, IReadableDatabase $db)
Loads a LogEntry with the given id from database.DatabaseLogEntry|null
getTimestamp()
Get the timestamp when the action was executed.string TS_MW timestamp, a string with 14 digits
getId()
Returns the unique database id.int
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
Represents a title within MediaWiki.
Definition Title.php:79
Interface for objects representing user identity.
A database connection without write operations.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...