| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
m |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
use MediaWiki\Logger\LoggerFactory; |
| 27 |
use MediaWiki\MediaWikiServices; |
| 28 |
use MediaWiki\Title\Title; |
| 29 |
use MediaWiki\User\UserIdentity; |
| 30 |
use Wikimedia\Rdbms\IReadableDatabase; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
class RCDatabaseLogEntry extends DatabaseLogEntry { |
| 39 |
|
| 40 |
public static function newFromId( $id, IReadableDatabase $db ) { |
| 41 |
|
| 42 |
|
| 43 |
throw new LogicException( 'Not implemented!' ); |
| 44 |
} |
| 45 |
|
| 46 |
public static function getSelectQueryData() { |
| 47 |
|
| 48 |
|
| 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 |
|
| 72 |
public function getPerformerIdentity(): UserIdentity { |
| 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 |
|
| 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 |
} |