MediaWiki master
RCDatabaseLogEntry.php
Go to the documentation of this file.
1<?php
12namespace MediaWiki\Logging;
13
14use InvalidArgumentException;
15use LogicException;
21use Wikimedia\Timestamp\TimestampFormat as TS;
22
30
32 public static function newFromId( $id, IReadableDatabase $db ) {
33 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
34 // Make the LSP violation explicit to prevent sneaky failures
35 throw new LogicException( 'Not implemented!' );
36 }
37
39 public static function getSelectQueryData() {
40 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
41 // Make the LSP violation explicit to prevent sneaky failures
42 throw new LogicException( 'Not implemented!' );
43 }
44
46 public function getId() {
47 return $this->row->rc_logid;
48 }
49
51 protected function getRawParameters() {
52 return $this->row->rc_params;
53 }
54
56 public function getAssociatedRevId() {
57 return $this->row->rc_this_oldid;
58 }
59
61 public function getType() {
62 return $this->row->rc_log_type;
63 }
64
66 public function getSubtype() {
67 return $this->row->rc_log_action;
68 }
69
72 if ( !$this->performer ) {
73 $actorStore = MediaWikiServices::getInstance()->getActorStore();
74 $userFactory = MediaWikiServices::getInstance()->getUserFactory();
75 if ( isset( $this->row->rc_actor ) ) {
76 try {
77 $this->performer = $actorStore->newActorFromRowFields(
78 $this->row->rc_user ?? 0,
79 $this->row->rc_user_text,
80 $this->row->rc_actor
81 );
82 } catch ( InvalidArgumentException $e ) {
83 $this->performer = $actorStore->getUnknownActor();
84 LoggerFactory::getInstance( 'logentry' )->warning(
85 'Failed to instantiate RC log entry performer', [
86 'exception' => $e,
87 'log_id' => $this->getId()
88 ]
89 );
90 }
91 } elseif ( isset( $this->row->rc_user ) ) {
92 $this->performer = $userFactory->newFromId( $this->row->rc_user )->getUser();
93 } elseif ( isset( $this->row->rc_user_text ) ) {
94 $user = $userFactory->newFromName( $this->row->rc_user_text );
95 if ( $user ) {
96 $this->performer = $user->getUser();
97 } else {
98 $this->performer = $actorStore->getUnknownActor();
99 LoggerFactory::getInstance( 'logentry' )->warning(
100 'Failed to instantiate RC log entry performer', [
101 'rc_user_text' => $this->row->rc_user_text,
102 'log_id' => $this->getId()
103 ]
104 );
105 }
106 }
107 }
108 return $this->performer;
109 }
110
112 public function getTarget() {
113 $namespace = $this->row->rc_namespace;
114 $page = $this->row->rc_title;
115 return Title::makeTitle( $namespace, $page );
116 }
117
119 public function getTimestamp() {
120 return wfTimestamp( TS::MW, $this->row->rc_timestamp );
121 }
122
124 public function getComment() {
125 $services = MediaWikiServices::getInstance();
126
127 return $services->getCommentStore()
128 // Legacy because the row may have used RecentChange::selectFields()
129 ->getCommentLegacy(
130 $services->getConnectionProvider()->getReplicaDatabase(),
131 'rc_comment',
132 $this->row
133 )->text;
134 }
135
137 public function getDeleted() {
138 return $this->row->rc_deleted;
139 }
140}
141
143class_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:68
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:69
Interface for objects representing user identity.
A database connection without write operations.