MediaWiki REL1_39
RCDatabaseLogEntry.php
Go to the documentation of this file.
1<?php
30
38
39 public static function newFromId( $id, IDatabase $db ) {
40 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
41 // Make the LSP violation explicit to prevent sneaky failures
42 throw new LogicException( 'Not implemented!' );
43 }
44
45 public static function getSelectQueryData() {
46 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
47 // Make the LSP violation explicit to prevent sneaky failures
48 throw new LogicException( 'Not implemented!' );
49 }
50
51 public function getId() {
52 return $this->row->rc_logid;
53 }
54
55 protected function getRawParameters() {
56 return $this->row->rc_params;
57 }
58
59 public function getAssociatedRevId() {
60 return $this->row->rc_this_oldid;
61 }
62
63 public function getType() {
64 return $this->row->rc_log_type;
65 }
66
67 public function getSubtype() {
68 return $this->row->rc_log_action;
69 }
70
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
111 public function getTarget() {
112 $namespace = $this->row->rc_namespace;
113 $page = $this->row->rc_title;
114 return Title::makeTitle( $namespace, $page );
115 }
116
117 public function getTimestamp() {
118 return wfTimestamp( TS_MW, $this->row->rc_timestamp );
119 }
120
121 public function getComment() {
122 return CommentStore::getStore()
123 // Legacy because the row may have used RecentChange::selectFields()
124 ->getCommentLegacy( wfGetDB( DB_REPLICA ), 'rc_comment', $this->row )->text;
125 }
126
127 public function getDeleted() {
128 return $this->row->rc_deleted;
129 }
130}
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Definition WebStart.php:82
A value class to process existing log entries.
UserIdentity $performer
PSR-3 logger instance factory.
Service locator for MediaWiki core services.
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 newFromId( $id, IDatabase $db)
Loads a LogEntry with the given id from database.
static getSelectQueryData()
Returns array of information that is needed for querying log entries.
getSubtype()
The log subtype.
getComment()
Get the user provided comment.
getDeleted()
Get the access restriction.
getRawParameters()
Returns whatever is stored in the database field.
getId()
Returns the unique database id.
getType()
The main log type.
Interface for objects representing user identity.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:39
const DB_REPLICA
Definition defines.php:26