MediaWiki master
RCDatabaseLogEntry.php
Go to the documentation of this file.
1<?php
31
39
40 public static function newFromId( $id, IReadableDatabase $db ) {
41 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
42 // Make the LSP violation explicit to prevent sneaky failures
43 throw new LogicException( 'Not implemented!' );
44 }
45
46 public static function getSelectQueryData() {
47 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
48 // Make the LSP violation explicit to prevent sneaky failures
49 throw new LogicException( 'Not implemented!' );
50 }
51
52 public function getId() {
53 return $this->row->rc_logid;
54 }
55
56 protected function getRawParameters() {
57 return $this->row->rc_params;
58 }
59
60 public function getAssociatedRevId() {
61 return $this->row->rc_this_oldid;
62 }
63
64 public function getType() {
65 return $this->row->rc_log_type;
66 }
67
68 public function getSubtype() {
69 return $this->row->rc_log_action;
70 }
71
73 if ( !$this->performer ) {
74 $actorStore = MediaWikiServices::getInstance()->getActorStore();
75 $userFactory = MediaWikiServices::getInstance()->getUserFactory();
76 if ( isset( $this->row->rc_actor ) ) {
77 try {
78 $this->performer = $actorStore->newActorFromRowFields(
79 $this->row->rc_user ?? 0,
80 $this->row->rc_user_text,
81 $this->row->rc_actor
82 );
83 } catch ( InvalidArgumentException $e ) {
84 $this->performer = $actorStore->getUnknownActor();
85 LoggerFactory::getInstance( 'logentry' )->warning(
86 'Failed to instantiate RC log entry performer', [
87 'exception' => $e,
88 'log_id' => $this->getId()
89 ]
90 );
91 }
92 } elseif ( isset( $this->row->rc_user ) ) {
93 $this->performer = $userFactory->newFromId( $this->row->rc_user )->getUser();
94 } elseif ( isset( $this->row->rc_user_text ) ) {
95 $user = $userFactory->newFromName( $this->row->rc_user_text );
96 if ( $user ) {
97 $this->performer = $user->getUser();
98 } else {
99 $this->performer = $actorStore->getUnknownActor();
100 LoggerFactory::getInstance( 'logentry' )->warning(
101 'Failed to instantiate RC log entry performer', [
102 'rc_user_text' => $this->row->rc_user_text,
103 'log_id' => $this->getId()
104 ]
105 );
106 }
107 }
108 }
109 return $this->performer;
110 }
111
112 public function getTarget() {
113 $namespace = $this->row->rc_namespace;
114 $page = $this->row->rc_title;
115 return Title::makeTitle( $namespace, $page );
116 }
117
118 public function getTimestamp() {
119 return wfTimestamp( TS_MW, $this->row->rc_timestamp );
120 }
121
122 public function getComment() {
123 $services = MediaWikiServices::getInstance();
124
125 return $services->getCommentStore()
126 // Legacy because the row may have used RecentChange::selectFields()
127 ->getCommentLegacy(
128 $services->getConnectionProvider()->getReplicaDatabase(),
129 'rc_comment',
130 $this->row
131 )->text;
132 }
133
134 public function getDeleted() {
135 return $this->row->rc_deleted;
136 }
137}
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:81
A value class to process existing log entries.
UserIdentity $performer
Create PSR-3 logger objects.
Service locator for MediaWiki core services.
Represents a title within MediaWiki.
Definition Title.php:78
A subclass of DatabaseLogEntry for objects constructed from entries in the recentchanges table (rathe...
getTimestamp()
Get the timestamp when the action was executed.
getTarget()
Get the target page of this action.
static getSelectQueryData()
Returns array of information that is needed for querying log entries.
getSubtype()
The log subtype.
getComment()
Get the user provided comment.
static newFromId( $id, IReadableDatabase $db)
Loads a LogEntry with the given id from database.
getDeleted()
Get the access restriction.
getRawParameters()
Returns whatever is stored in the database field (typically a serialized associative array but very o...
getId()
Returns the unique database id.
getType()
The main log type.
Interface for objects representing user identity.
A database connection without write operations.