Split logging classes to individual files
[lhc/web/wiklou.git] / includes / logging / RCDatabaseLogEntry.php
1 <?php
2 /**
3 * Contains a class for dealing with recent changes database log entries
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @author Niklas Laxström
22 * @license GPL-2.0-or-later
23 * @since 1.19
24 */
25
26 /**
27 * A subclass of DatabaseLogEntry for objects constructed from entries in the
28 * recentchanges table (rather than the logging table).
29 */
30 class RCDatabaseLogEntry extends DatabaseLogEntry {
31
32 public function getId() {
33 return $this->row->rc_logid;
34 }
35
36 protected function getRawParameters() {
37 return $this->row->rc_params;
38 }
39
40 public function getAssociatedRevId() {
41 return $this->row->rc_this_oldid;
42 }
43
44 public function getType() {
45 return $this->row->rc_log_type;
46 }
47
48 public function getSubtype() {
49 return $this->row->rc_log_action;
50 }
51
52 public function getPerformer() {
53 if ( !$this->performer ) {
54 $actorId = isset( $this->row->rc_actor ) ? (int)$this->row->rc_actor : 0;
55 $userId = (int)$this->row->rc_user;
56 if ( $actorId !== 0 ) {
57 $this->performer = User::newFromActorId( $actorId );
58 } elseif ( $userId !== 0 ) {
59 $this->performer = User::newFromId( $userId );
60 } else {
61 $userText = $this->row->rc_user_text;
62 // Might be an IP, don't validate the username
63 $this->performer = User::newFromName( $userText, false );
64 }
65 }
66
67 return $this->performer;
68 }
69
70 public function getTarget() {
71 $namespace = $this->row->rc_namespace;
72 $page = $this->row->rc_title;
73 return Title::makeTitle( $namespace, $page );
74 }
75
76 public function getTimestamp() {
77 return wfTimestamp( TS_MW, $this->row->rc_timestamp );
78 }
79
80 public function getComment() {
81 return CommentStore::getStore()
82 // Legacy because the row may have used RecentChange::selectFields()
83 ->getCommentLegacy( wfGetDB( DB_REPLICA ), 'rc_comment', $this->row )->text;
84 }
85
86 public function getDeleted() {
87 return $this->row->rc_deleted;
88 }
89 }