RCDatabaseLogEntry: Stop returning an unknown actor if rc_user is given
In all cases that rc_actor is not given the function returns an unknown actor as ActorStore::newActorFromRowFields() throw exception in that cases. It is too strict because, for instance, RecentChange::newLogEntry() does not provide the attribute. This changes it. Bug: T286979 Change-Id: I5668053c30c18755536bfcb98524e79eb2827dda
This commit is contained in:
parent
61b534829a
commit
cf971e0d46
1 changed files with 31 additions and 15 deletions
|
|
@ -71,23 +71,39 @@ class RCDatabaseLogEntry extends DatabaseLogEntry {
|
|||
public function getPerformerIdentity(): UserIdentity {
|
||||
if ( !$this->performer ) {
|
||||
$actorStore = MediaWikiServices::getInstance()->getActorStore();
|
||||
try {
|
||||
$this->performer = $actorStore->newActorFromRowFields(
|
||||
$this->row->rc_user ?? 0,
|
||||
$this->row->rc_user_text,
|
||||
$this->row->rc_actor ?? null
|
||||
);
|
||||
} catch ( InvalidArgumentException $e ) {
|
||||
LoggerFactory::getInstance( 'logentry' )->warning(
|
||||
'Failed to instantiate RC log entry performer', [
|
||||
'exception' => $e,
|
||||
'log_id' => $this->getId()
|
||||
]
|
||||
);
|
||||
$this->performer = $actorStore->getUnknownActor();
|
||||
$userFactory = MediaWikiServices::getInstance()->getUserFactory();
|
||||
if ( isset( $this->row->rc_actor ) ) {
|
||||
try {
|
||||
$this->performer = $actorStore->newActorFromRowFields(
|
||||
$this->row->rc_user ?? 0,
|
||||
$this->row->rc_user_text,
|
||||
$this->row->rc_actor
|
||||
);
|
||||
} catch ( InvalidArgumentException $e ) {
|
||||
LoggerFactory::getInstance( 'logentry' )->warning(
|
||||
'Failed to instantiate RC log entry performer', [
|
||||
'exception' => $e,
|
||||
'log_id' => $this->getId()
|
||||
]
|
||||
);
|
||||
}
|
||||
} elseif ( isset( $this->row->rc_user ) ) {
|
||||
$this->performer = $userFactory->newFromId( $this->row->rc_user )->getUser();
|
||||
} elseif ( isset( $this->row->rc_user_text ) ) {
|
||||
$user = $userFactory->newFromName( $this->row->rc_user_text );
|
||||
if ( $user ) {
|
||||
$this->performer = $user->getUser();
|
||||
} else {
|
||||
LoggerFactory::getInstance( 'logentry' )->warning(
|
||||
'Failed to instantiate RC log entry performer', [
|
||||
'rc_user_text' => $this->row->rc_user_text,
|
||||
'log_id' => $this->getId()
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->performer;
|
||||
return $this->performer ?: $actorStore->getUnknownActor();
|
||||
}
|
||||
|
||||
public function getTarget() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue