MediaWiki master
RCDatabaseLogEntry.php
Go to the documentation of this file.
1<?php
26namespace MediaWiki\Logging;
27
28use InvalidArgumentException;
29use LogicException;
35
43
44 public static function newFromId( $id, IReadableDatabase $db ) {
45 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
46 // Make the LSP violation explicit to prevent sneaky failures
47 throw new LogicException( 'Not implemented!' );
48 }
49
50 public static function getSelectQueryData() {
51 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
52 // Make the LSP violation explicit to prevent sneaky failures
53 throw new LogicException( 'Not implemented!' );
54 }
55
56 public function getId() {
57 return $this->row->rc_logid;
58 }
59
60 protected function getRawParameters() {
61 return $this->row->rc_params;
62 }
63
64 public function getAssociatedRevId() {
65 return $this->row->rc_this_oldid;
66 }
67
68 public function getType() {
69 return $this->row->rc_log_type;
70 }
71
72 public function getSubtype() {
73 return $this->row->rc_log_action;
74 }
75
77 if ( !$this->performer ) {
78 $actorStore = MediaWikiServices::getInstance()->getActorStore();
79 $userFactory = MediaWikiServices::getInstance()->getUserFactory();
80 if ( isset( $this->row->rc_actor ) ) {
81 try {
82 $this->performer = $actorStore->newActorFromRowFields(
83 $this->row->rc_user ?? 0,
84 $this->row->rc_user_text,
85 $this->row->rc_actor
86 );
87 } catch ( InvalidArgumentException $e ) {
88 $this->performer = $actorStore->getUnknownActor();
89 LoggerFactory::getInstance( 'logentry' )->warning(
90 'Failed to instantiate RC log entry performer', [
91 'exception' => $e,
92 'log_id' => $this->getId()
93 ]
94 );
95 }
96 } elseif ( isset( $this->row->rc_user ) ) {
97 $this->performer = $userFactory->newFromId( $this->row->rc_user )->getUser();
98 } elseif ( isset( $this->row->rc_user_text ) ) {
99 $user = $userFactory->newFromName( $this->row->rc_user_text );
100 if ( $user ) {
101 $this->performer = $user->getUser();
102 } else {
103 $this->performer = $actorStore->getUnknownActor();
104 LoggerFactory::getInstance( 'logentry' )->warning(
105 'Failed to instantiate RC log entry performer', [
106 'rc_user_text' => $this->row->rc_user_text,
107 'log_id' => $this->getId()
108 ]
109 );
110 }
111 }
112 }
113 return $this->performer;
114 }
115
116 public function getTarget() {
117 $namespace = $this->row->rc_namespace;
118 $page = $this->row->rc_title;
119 return Title::makeTitle( $namespace, $page );
120 }
121
122 public function getTimestamp() {
123 return wfTimestamp( TS_MW, $this->row->rc_timestamp );
124 }
125
126 public function getComment() {
127 $services = MediaWikiServices::getInstance();
128
129 return $services->getCommentStore()
130 // Legacy because the row may have used RecentChange::selectFields()
131 ->getCommentLegacy(
132 $services->getConnectionProvider()->getReplicaDatabase(),
133 'rc_comment',
134 $this->row
135 )->text;
136 }
137
138 public function getDeleted() {
139 return $this->row->rc_deleted;
140 }
141}
142
144class_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:81
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.
getComment()
Get the user provided comment.
getTarget()
Get the target page of this action.
getRawParameters()
Returns whatever is stored in the database field (typically a serialized associative array but very o...
getDeleted()
Get the access restriction.
static newFromId( $id, IReadableDatabase $db)
Loads a LogEntry with the given id from database.
getTimestamp()
Get the timestamp when the action was executed.
getId()
Returns the unique database id.
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:78
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...