Stop using legacy ActorMigration field "log_user"
Bug: T278917 Change-Id: I1b78bad7e1fa43f5f82908567a7daad9c6cc79b9
This commit is contained in:
parent
fd01c53778
commit
83e184670c
16 changed files with 113 additions and 137 deletions
|
|
@ -3020,7 +3020,7 @@ class EditPage implements IEditObject {
|
|||
$this->showFormBeforeText();
|
||||
|
||||
if ( $this->wasDeletedSinceLastEdit() && $this->formtype == 'save' ) {
|
||||
$username = $this->lastDelete->user_name;
|
||||
$username = $this->lastDelete->actor_name;
|
||||
$comment = CommentStore::getStore()
|
||||
->getComment( 'log_comment', $this->lastDelete )->text;
|
||||
|
||||
|
|
@ -4010,9 +4010,8 @@ class EditPage implements IEditObject {
|
|||
protected function getLastDelete() {
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$commentQuery = CommentStore::getStore()->getJoin( 'log_comment' );
|
||||
$actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
|
||||
$data = $dbr->selectRow(
|
||||
array_merge( [ 'logging' ], $commentQuery['tables'], $actorQuery['tables'], [ 'user' ] ),
|
||||
array_merge( [ 'logging' ], $commentQuery['tables'], [ 'actor' ] ),
|
||||
[
|
||||
'log_type',
|
||||
'log_action',
|
||||
|
|
@ -4021,8 +4020,8 @@ class EditPage implements IEditObject {
|
|||
'log_title',
|
||||
'log_params',
|
||||
'log_deleted',
|
||||
'user_name'
|
||||
] + $commentQuery['fields'] + $actorQuery['fields'],
|
||||
'actor_name'
|
||||
] + $commentQuery['fields'],
|
||||
[
|
||||
'log_namespace' => $this->mTitle->getNamespace(),
|
||||
'log_title' => $this->mTitle->getDBkey(),
|
||||
|
|
@ -4032,13 +4031,13 @@ class EditPage implements IEditObject {
|
|||
__METHOD__,
|
||||
[ 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' ],
|
||||
[
|
||||
'user' => [ 'JOIN', 'user_id=' . $actorQuery['fields']['log_user'] ],
|
||||
] + $commentQuery['joins'] + $actorQuery['joins']
|
||||
'actor' => [ 'JOIN', 'actor_id=log_actor' ],
|
||||
] + $commentQuery['joins']
|
||||
);
|
||||
// Quick paranoid permission checks...
|
||||
if ( is_object( $data ) ) {
|
||||
if ( $data->log_deleted & LogPage::DELETED_USER ) {
|
||||
$data->user_name = $this->context->msg( 'rev-deleted-user' )->escaped();
|
||||
$data->actor_name = $this->context->msg( 'rev-deleted-user' )->escaped();
|
||||
}
|
||||
|
||||
if ( $data->log_deleted & LogPage::DELETED_COMMENT ) {
|
||||
|
|
|
|||
|
|
@ -76,15 +76,9 @@ class ApiQueryLogEvents extends ApiQueryBase {
|
|||
$this->addWhere( $hideLogs );
|
||||
}
|
||||
|
||||
$actorMigration = ActorMigration::newMigration();
|
||||
$actorQuery = $actorMigration->getJoin( 'log_user' );
|
||||
$this->addTables( 'logging' );
|
||||
$this->addTables( $actorQuery['tables'] );
|
||||
$this->addTables( [ 'user', 'page' ] );
|
||||
$this->addJoinConds( $actorQuery['joins'] );
|
||||
$this->addTables( [ 'logging', 'actor', 'page' ] );
|
||||
$this->addJoinConds( [
|
||||
'user' => [ 'LEFT JOIN',
|
||||
'user_id=' . $actorQuery['fields']['log_user'] ],
|
||||
'actor' => [ 'JOIN', 'actor_id=log_actor' ],
|
||||
'page' => [ 'LEFT JOIN',
|
||||
[ 'log_namespace=page_namespace',
|
||||
'log_title=page_title' ] ] ] );
|
||||
|
|
@ -102,8 +96,8 @@ class ApiQueryLogEvents extends ApiQueryBase {
|
|||
// join at query time. This leads to different results in various
|
||||
// scenarios, e.g. deletion, recreation.
|
||||
$this->addFieldsIf( 'log_page', $this->fld_ids );
|
||||
$this->addFieldsIf( $actorQuery['fields'] + [ 'user_name' ], $this->fld_user );
|
||||
$this->addFieldsIf( $actorQuery['fields'], $this->fld_userid );
|
||||
$this->addFieldsIf( [ 'actor_name', 'actor_user' ], $this->fld_user );
|
||||
$this->addFieldsIf( 'actor_user', $this->fld_userid );
|
||||
$this->addFieldsIf(
|
||||
[ 'log_namespace', 'log_title' ],
|
||||
$this->fld_title || $this->fld_parsedcomment
|
||||
|
|
@ -188,10 +182,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
|
|||
|
||||
$user = $params['user'];
|
||||
if ( $user !== null ) {
|
||||
// Note the joins in $q are the same as those from ->getJoin() above
|
||||
// so we only need to add 'conds' here.
|
||||
$q = $actorMigration->getWhere( $db, 'log_user', $params['user'] );
|
||||
$this->addWhere( $q['conds'] );
|
||||
$this->addWhereFld( 'actor_name', $user );
|
||||
|
||||
// Remove after T270620 is resolved.
|
||||
$index = $db->indexExists( 'logging', 'times', __METHOD__ ) ? 'times' : 'log_times';
|
||||
|
|
@ -331,13 +322,13 @@ class ApiQueryLogEvents extends ApiQueryBase {
|
|||
}
|
||||
if ( LogEventsList::userCan( $row, LogPage::DELETED_USER, $user ) ) {
|
||||
if ( $this->fld_user ) {
|
||||
$vals['user'] = $row->user_name ?? $row->log_user_text;
|
||||
$vals['user'] = $row->actor_name;
|
||||
}
|
||||
if ( $this->fld_userid ) {
|
||||
$vals['userid'] = (int)$row->log_user;
|
||||
$vals['userid'] = (int)$row->actor_user;
|
||||
}
|
||||
|
||||
if ( !$row->log_user ) {
|
||||
if ( !$row->actor_user ) {
|
||||
$vals['anon'] = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -457,7 +448,6 @@ class ApiQueryLogEvents extends ApiQueryBase {
|
|||
'user' => [
|
||||
ApiBase::PARAM_TYPE => 'user',
|
||||
UserDef::PARAM_ALLOWED_USER_TYPES => [ 'name', 'ip', 'id', 'interwiki' ],
|
||||
UserDef::PARAM_RETURN_OBJECT => true,
|
||||
],
|
||||
'title' => null,
|
||||
'namespace' => [
|
||||
|
|
|
|||
|
|
@ -325,23 +325,22 @@ class WikiExporter {
|
|||
$result = null; // Assuring $result is not undefined, if exception occurs early
|
||||
|
||||
$commentQuery = CommentStore::getStore()->getJoin( 'log_comment' );
|
||||
$actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
|
||||
|
||||
$tables = array_merge(
|
||||
[ 'logging' ], $commentQuery['tables'], $actorQuery['tables'], [ 'user' ]
|
||||
[ 'logging', 'actor' ], $commentQuery['tables']
|
||||
);
|
||||
$fields = [
|
||||
'log_id', 'log_type', 'log_action', 'log_timestamp', 'log_namespace',
|
||||
'log_title', 'log_params', 'log_deleted', 'user_name'
|
||||
] + $commentQuery['fields'] + $actorQuery['fields'];
|
||||
'log_title', 'log_params', 'log_deleted', 'actor_user', 'actor_name'
|
||||
] + $commentQuery['fields'];
|
||||
$options = [
|
||||
'ORDER BY' => 'log_id',
|
||||
'USE INDEX' => [ 'logging' => 'PRIMARY' ],
|
||||
'LIMIT' => self::BATCH_SIZE,
|
||||
];
|
||||
$joins = [
|
||||
'user' => [ 'JOIN', 'user_id = ' . $actorQuery['fields']['log_user'] ]
|
||||
] + $commentQuery['joins'] + $actorQuery['joins'];
|
||||
'actor' => [ 'JOIN', 'actor_id=log_actor' ]
|
||||
] + $commentQuery['joins'];
|
||||
|
||||
$lastLogId = 0;
|
||||
while ( true ) {
|
||||
|
|
|
|||
|
|
@ -589,7 +589,7 @@ class XmlDumpWriter {
|
|||
if ( $row->log_deleted & LogPage::DELETED_USER ) {
|
||||
$out .= " " . Xml::element( 'contributor', [ 'deleted' => 'deleted' ] ) . "\n";
|
||||
} else {
|
||||
$out .= $this->writeContributor( $row->log_user, $row->user_name, " " );
|
||||
$out .= $this->writeContributor( $row->actor_user, $row->actor_name, " " );
|
||||
}
|
||||
|
||||
if ( $row->log_deleted & LogPage::DELETED_COMMENT ) {
|
||||
|
|
|
|||
|
|
@ -703,15 +703,17 @@ class WikiRevision implements ImportableUploadRevision, ImportableOldRevision {
|
|||
. $this->timestamp );
|
||||
return false;
|
||||
}
|
||||
$actorId = MediaWikiServices::getInstance()->getActorNormalization()
|
||||
->acquireActorId( $user, $dbw );
|
||||
$data = [
|
||||
'log_type' => $this->type,
|
||||
'log_action' => $this->action,
|
||||
'log_timestamp' => $dbw->timestamp( $this->timestamp ),
|
||||
'log_actor' => $actorId,
|
||||
'log_namespace' => $this->getTitle()->getNamespace(),
|
||||
'log_title' => $this->getTitle()->getDBkey(),
|
||||
'log_params' => $this->params
|
||||
] + CommentStore::getStore()->insert( $dbw, 'log_comment', $this->getComment() )
|
||||
+ ActorMigration::newMigration()->getInsertValues( $dbw, 'log_user', $user );
|
||||
] + CommentStore::getStore()->insert( $dbw, 'log_comment', $this->getComment() );
|
||||
$dbw->insert( 'logging', $data, __METHOD__ );
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
* @since 1.19
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
|
||||
|
|
@ -41,26 +42,40 @@ class DatabaseLogEntry extends LogEntryBase {
|
|||
* log entries. Array contains the following keys:
|
||||
* tables, fields, conds, options and join_conds
|
||||
*
|
||||
* Since 1.34, log_user and log_user_text have not been present in the
|
||||
* database, but they continue to be available in query results as
|
||||
* aliases.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getSelectQueryData() {
|
||||
$commentQuery = CommentStore::getStore()->getJoin( 'log_comment' );
|
||||
$actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
|
||||
|
||||
$tables = array_merge(
|
||||
[ 'logging' ], $commentQuery['tables'], $actorQuery['tables'], [ 'user' ]
|
||||
[
|
||||
'logging',
|
||||
'logging_actor' => 'actor',
|
||||
'user'
|
||||
],
|
||||
$commentQuery['tables']
|
||||
);
|
||||
$fields = [
|
||||
'log_id', 'log_type', 'log_action', 'log_timestamp',
|
||||
'log_namespace', 'log_title', // unused log_page
|
||||
'log_params', 'log_deleted',
|
||||
'user_id', 'user_name', 'user_editcount',
|
||||
] + $commentQuery['fields'] + $actorQuery['fields'];
|
||||
'user_id',
|
||||
'user_name',
|
||||
'user_editcount',
|
||||
'log_actor',
|
||||
'log_user' => 'logging_actor.actor_user',
|
||||
'log_user_text' => 'logging_actor.actor_name'
|
||||
] + $commentQuery['fields'];
|
||||
|
||||
$joins = [
|
||||
'logging_actor' => [ 'JOIN', 'actor_id=log_actor' ],
|
||||
// IPs don't have an entry in user table
|
||||
'user' => [ 'LEFT JOIN', 'user_id=' . $actorQuery['fields']['log_user'] ],
|
||||
] + $commentQuery['joins'] + $actorQuery['joins'];
|
||||
'user' => [ 'LEFT JOIN', 'user_id=logging_actor.actor_user' ],
|
||||
] + $commentQuery['joins'];
|
||||
|
||||
return [
|
||||
'tables' => $tables,
|
||||
|
|
@ -193,22 +208,12 @@ class DatabaseLogEntry extends LogEntryBase {
|
|||
|
||||
protected function getPerformerUser(): User {
|
||||
if ( !$this->performer ) {
|
||||
$actorId = isset( $this->row->log_actor ) ? (int)$this->row->log_actor : 0;
|
||||
$userId = (int)$this->row->log_user;
|
||||
if ( $userId !== 0 || $actorId !== 0 ) {
|
||||
// logged-in users
|
||||
if ( isset( $this->row->user_name ) ) {
|
||||
$this->performer = User::newFromRow( $this->row );
|
||||
} elseif ( $actorId !== 0 ) {
|
||||
$this->performer = User::newFromActorId( $actorId );
|
||||
} else {
|
||||
$this->performer = User::newFromId( $userId );
|
||||
}
|
||||
} else {
|
||||
// IP users
|
||||
$userText = $this->row->log_user_text;
|
||||
$this->performer = User::newFromName( $userText, false );
|
||||
}
|
||||
$this->performer = MediaWikiServices::getInstance()->getUserFactory()
|
||||
->newFromAnyId(
|
||||
$this->row->user_id ?? 0, // left join failure means anonymous
|
||||
$this->row->log_user_text,
|
||||
$this->row->log_actor
|
||||
);
|
||||
}
|
||||
|
||||
return $this->performer;
|
||||
|
|
|
|||
|
|
@ -101,10 +101,13 @@ class LogPage {
|
|||
$dbw = wfGetDB( DB_MASTER );
|
||||
|
||||
$now = wfTimestampNow();
|
||||
$actorId = MediaWikiServices::getInstance()->getActorNormalization()
|
||||
->acquireActorId( $this->performer, $dbw );
|
||||
$data = [
|
||||
'log_type' => $this->type,
|
||||
'log_action' => $this->action,
|
||||
'log_timestamp' => $dbw->timestamp( $now ),
|
||||
'log_actor' => $actorId,
|
||||
'log_namespace' => $this->target->getNamespace(),
|
||||
'log_title' => $this->target->getDBkey(),
|
||||
'log_page' => $this->target->getArticleID(),
|
||||
|
|
@ -115,7 +118,6 @@ class LogPage {
|
|||
'log_comment',
|
||||
$this->comment
|
||||
);
|
||||
$data += ActorMigration::newMigration()->getInsertValues( $dbw, 'log_user', $this->performer );
|
||||
$dbw->insert( 'logging', $data, __METHOD__ );
|
||||
$newId = $dbw->insertId();
|
||||
|
||||
|
|
|
|||
|
|
@ -277,6 +277,9 @@ class ManualLogEntry extends LogEntryBase implements Taggable {
|
|||
$this->timestamp = wfTimestampNow();
|
||||
}
|
||||
|
||||
$actorId = \MediaWiki\MediaWikiServices::getInstance()->getActorStore()
|
||||
->acquireActorId( $this->getPerformerIdentity(), $dbw );
|
||||
|
||||
// Trim spaces on user supplied text
|
||||
$comment = trim( $this->getComment() );
|
||||
|
||||
|
|
@ -294,6 +297,7 @@ class ManualLogEntry extends LogEntryBase implements Taggable {
|
|||
'log_type' => $this->getType(),
|
||||
'log_action' => $this->getSubtype(),
|
||||
'log_timestamp' => $dbw->timestamp( $this->getTimestamp() ),
|
||||
'log_actor' => $actorId,
|
||||
'log_namespace' => $this->getTarget()->getNamespace(),
|
||||
'log_title' => $this->getTarget()->getDBkey(),
|
||||
'log_page' => $this->getTarget()->getArticleID(),
|
||||
|
|
@ -303,8 +307,6 @@ class ManualLogEntry extends LogEntryBase implements Taggable {
|
|||
$data['log_deleted'] = $this->deleted;
|
||||
}
|
||||
$data += CommentStore::getStore()->insert( $dbw, 'log_comment', $comment );
|
||||
$data += ActorMigration::newMigration()
|
||||
->getInsertValues( $dbw, 'log_user', $this->getPerformerIdentity() );
|
||||
|
||||
$dbw->insert( 'logging', $data, __METHOD__ );
|
||||
$this->id = $dbw->insertId();
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ class RevDelLogItem extends RevDelItem {
|
|||
}
|
||||
if ( LogEventsList::userCan( $this->row, LogPage::DELETED_USER, $user ) ) {
|
||||
$ret += [
|
||||
'userid' => $this->row->log_user,
|
||||
'userid' => $this->row->log_user ?? 0,
|
||||
'user' => $this->row->log_user_text,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,18 +28,15 @@ use Wikimedia\Rdbms\LBFactory;
|
|||
*/
|
||||
class RevDelLogList extends RevDelList {
|
||||
|
||||
/** @var ActorMigration */
|
||||
private $actorMigration;
|
||||
|
||||
/** @var CommentStore */
|
||||
private $commentStore;
|
||||
|
||||
/**
|
||||
* @internal Use RevisionDeleter
|
||||
* @param IContextSource $context
|
||||
* @param Title $title
|
||||
* @param array $ids
|
||||
* @param LBFactory $lbFactory
|
||||
* @param ActorMigration $actorMigration
|
||||
* @param CommentStore $commentStore
|
||||
*/
|
||||
public function __construct(
|
||||
|
|
@ -47,11 +44,9 @@ class RevDelLogList extends RevDelList {
|
|||
Title $title,
|
||||
array $ids,
|
||||
LBFactory $lbFactory,
|
||||
ActorMigration $actorMigration,
|
||||
CommentStore $commentStore
|
||||
) {
|
||||
parent::__construct( $context, $title, $ids, $lbFactory );
|
||||
$this->actorMigration = $actorMigration;
|
||||
$this->commentStore = $commentStore;
|
||||
}
|
||||
|
||||
|
|
@ -94,25 +89,29 @@ class RevDelLogList extends RevDelList {
|
|||
$ids = array_map( 'intval', $this->ids );
|
||||
|
||||
$commentQuery = $this->commentStore->getJoin( 'log_comment' );
|
||||
$actorQuery = $this->actorMigration->getJoin( 'log_user' );
|
||||
|
||||
return $db->select(
|
||||
[ 'logging' ] + $commentQuery['tables'] + $actorQuery['tables'],
|
||||
[ 'logging', 'actor' ] + $commentQuery['tables'],
|
||||
[
|
||||
'log_id',
|
||||
'log_type',
|
||||
'log_action',
|
||||
'log_timestamp',
|
||||
'log_actor',
|
||||
'log_namespace',
|
||||
'log_title',
|
||||
'log_page',
|
||||
'log_params',
|
||||
'log_deleted'
|
||||
] + $commentQuery['fields'] + $actorQuery['fields'],
|
||||
'log_deleted',
|
||||
'log_user' => 'actor_user',
|
||||
'log_user_text' => 'actor_name'
|
||||
] + $commentQuery['fields'],
|
||||
[ 'log_id' => $ids ],
|
||||
__METHOD__,
|
||||
[ 'ORDER BY' => 'log_id DESC' ],
|
||||
$commentQuery['joins'] + $actorQuery['joins']
|
||||
[
|
||||
'actor' => [ 'JOIN', 'actor_id=log_actor' ]
|
||||
] + $commentQuery['joins']
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@ class RevisionDeleter {
|
|||
'class' => RevDelLogList::class,
|
||||
'services' => [
|
||||
'DBLoadBalancerFactory',
|
||||
'ActorMigration',
|
||||
'CommentStore',
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -143,7 +143,6 @@ class SpecialPageFactory {
|
|||
'LinkBatchFactory',
|
||||
'DBLoadBalancer',
|
||||
'CommentStore',
|
||||
'ActorMigration',
|
||||
'UserCache',
|
||||
]
|
||||
],
|
||||
|
|
|
|||
|
|
@ -42,9 +42,6 @@ class SpecialProtectedpages extends SpecialPage {
|
|||
/** @var CommentStore */
|
||||
private $commentStore;
|
||||
|
||||
/** @var ActorMigration */
|
||||
private $actorMigration;
|
||||
|
||||
/** @var UserCache */
|
||||
private $userCache;
|
||||
|
||||
|
|
@ -52,21 +49,18 @@ class SpecialProtectedpages extends SpecialPage {
|
|||
* @param LinkBatchFactory $linkBatchFactory
|
||||
* @param ILoadBalancer $loadBalancer
|
||||
* @param CommentStore $commentStore
|
||||
* @param ActorMigration $actorMigration
|
||||
* @param UserCache $userCache
|
||||
*/
|
||||
public function __construct(
|
||||
LinkBatchFactory $linkBatchFactory,
|
||||
ILoadBalancer $loadBalancer,
|
||||
CommentStore $commentStore,
|
||||
ActorMigration $actorMigration,
|
||||
UserCache $userCache
|
||||
) {
|
||||
parent::__construct( 'Protectedpages' );
|
||||
$this->linkBatchFactory = $linkBatchFactory;
|
||||
$this->loadBalancer = $loadBalancer;
|
||||
$this->commentStore = $commentStore;
|
||||
$this->actorMigration = $actorMigration;
|
||||
$this->userCache = $userCache;
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +97,6 @@ class SpecialProtectedpages extends SpecialPage {
|
|||
$this->linkBatchFactory,
|
||||
$this->loadBalancer,
|
||||
$this->commentStore,
|
||||
$this->actorMigration,
|
||||
$this->userCache
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,9 +34,6 @@ class ProtectedPagesPager extends TablePager {
|
|||
/** @var CommentStore */
|
||||
private $commentStore;
|
||||
|
||||
/** @var ActorMigration */
|
||||
private $actorMigration;
|
||||
|
||||
/** @var UserCache */
|
||||
private $userCache;
|
||||
|
||||
|
|
@ -55,7 +52,6 @@ class ProtectedPagesPager extends TablePager {
|
|||
* @param LinkBatchFactory $linkBatchFactory
|
||||
* @param ILoadBalancer $loadBalancer
|
||||
* @param CommentStore $commentStore
|
||||
* @param ActorMigration $actorMigration
|
||||
* @param UserCache $userCache
|
||||
*/
|
||||
public function __construct(
|
||||
|
|
@ -73,7 +69,6 @@ class ProtectedPagesPager extends TablePager {
|
|||
LinkBatchFactory $linkBatchFactory,
|
||||
ILoadBalancer $loadBalancer,
|
||||
CommentStore $commentStore,
|
||||
ActorMigration $actorMigration,
|
||||
UserCache $userCache
|
||||
) {
|
||||
// Set database before parent constructor to avoid setting it there with wfGetDB
|
||||
|
|
@ -90,7 +85,6 @@ class ProtectedPagesPager extends TablePager {
|
|||
$this->noredirect = (bool)$noredirect;
|
||||
$this->linkBatchFactory = $linkBatchFactory;
|
||||
$this->commentStore = $commentStore;
|
||||
$this->actorMigration = $actorMigration;
|
||||
$this->userCache = $userCache;
|
||||
}
|
||||
|
||||
|
|
@ -101,9 +95,8 @@ class ProtectedPagesPager extends TablePager {
|
|||
|
||||
foreach ( $result as $row ) {
|
||||
$lb->add( $row->page_namespace, $row->page_title );
|
||||
// field is nullable, maybe null on old protections
|
||||
if ( $row->log_user !== null ) {
|
||||
$userids[] = $row->log_user;
|
||||
if ( $row->actor_user !== null ) {
|
||||
$userids[] = $row->actor_user;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +123,7 @@ class ProtectedPagesPager extends TablePager {
|
|||
'log_timestamp' => 'protectedpages-timestamp',
|
||||
'pr_page' => 'protectedpages-page',
|
||||
'pr_expiry' => 'protectedpages-expiry',
|
||||
'log_user' => 'protectedpages-performer',
|
||||
'actor_user' => 'protectedpages-performer',
|
||||
'pr_params' => 'protectedpages-params',
|
||||
'log_comment' => 'protectedpages-reason',
|
||||
];
|
||||
|
|
@ -212,7 +205,7 @@ class ProtectedPagesPager extends TablePager {
|
|||
}
|
||||
break;
|
||||
|
||||
case 'log_user':
|
||||
case 'actor_user':
|
||||
// when timestamp is null, this is a old protection row
|
||||
if ( $row->log_timestamp === null ) {
|
||||
$formatted = Html::rawElement(
|
||||
|
|
@ -221,14 +214,14 @@ class ProtectedPagesPager extends TablePager {
|
|||
$this->msg( 'protectedpages-unknown-performer' )->escaped()
|
||||
);
|
||||
} else {
|
||||
$username = $this->userCache->getProp( $value, 'name' );
|
||||
$username = $row->actor_name;
|
||||
if ( LogEventsList::userCanBitfield(
|
||||
$row->log_deleted,
|
||||
LogPage::DELETED_USER,
|
||||
$this->getUser()
|
||||
) ) {
|
||||
if ( $username === false ) {
|
||||
$formatted = htmlspecialchars( $value );
|
||||
if ( !$value ) {
|
||||
$formatted = htmlspecialchars( $username );
|
||||
} else {
|
||||
$formatted = Linker::userLink( $value, $username )
|
||||
. Linker::userToolLinks( $value, $username );
|
||||
|
|
@ -317,12 +310,11 @@ class ProtectedPagesPager extends TablePager {
|
|||
}
|
||||
|
||||
$commentQuery = $this->commentStore->getJoin( 'log_comment' );
|
||||
$actorQuery = $this->actorMigration->getJoin( 'log_user' );
|
||||
|
||||
return [
|
||||
'tables' => [
|
||||
'page', 'page_restrictions', 'log_search',
|
||||
'logparen' => [ 'logging' ] + $commentQuery['tables'] + $actorQuery['tables'],
|
||||
'logparen' => [ 'logging', 'actor' ] + $commentQuery['tables'],
|
||||
],
|
||||
'fields' => [
|
||||
'pr_id',
|
||||
|
|
@ -335,7 +327,9 @@ class ProtectedPagesPager extends TablePager {
|
|||
'pr_cascade',
|
||||
'log_timestamp',
|
||||
'log_deleted',
|
||||
] + $commentQuery['fields'] + $actorQuery['fields'],
|
||||
'actor_name',
|
||||
'actor_user'
|
||||
] + $commentQuery['fields'],
|
||||
'conds' => $conds,
|
||||
'join_conds' => [
|
||||
'log_search' => [
|
||||
|
|
@ -347,8 +341,13 @@ class ProtectedPagesPager extends TablePager {
|
|||
'LEFT JOIN', [
|
||||
'ls_log_id = log_id'
|
||||
]
|
||||
],
|
||||
'actor' => [
|
||||
'JOIN', [
|
||||
'actor_id=log_actor'
|
||||
]
|
||||
]
|
||||
] + $commentQuery['joins'] + $actorQuery['joins']
|
||||
] + $commentQuery['joins']
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class DatabaseLogEntryTest extends MediaWikiIntegrationTestCase {
|
|||
'logging',
|
||||
'user',
|
||||
'comment_log_comment' => 'comment',
|
||||
'actor_log_user' => 'actor'
|
||||
'logging_actor' => 'actor'
|
||||
],
|
||||
'fields' => [
|
||||
'log_id',
|
||||
|
|
@ -82,15 +82,15 @@ class DatabaseLogEntryTest extends MediaWikiIntegrationTestCase {
|
|||
'log_comment_text' => 'comment_log_comment.comment_text',
|
||||
'log_comment_data' => 'comment_log_comment.comment_data',
|
||||
'log_comment_cid' => 'comment_log_comment.comment_id',
|
||||
'log_user' => 'actor_log_user.actor_user',
|
||||
'log_user_text' => 'actor_log_user.actor_name',
|
||||
'log_actor' => 'log_actor',
|
||||
'log_user' => 'logging_actor.actor_user',
|
||||
'log_user_text' => 'logging_actor.actor_name',
|
||||
'log_actor',
|
||||
],
|
||||
'options' => [],
|
||||
'join_conds' => [
|
||||
'user' => [ 'LEFT JOIN', 'user_id=actor_log_user.actor_user' ],
|
||||
'user' => [ 'LEFT JOIN', 'user_id=logging_actor.actor_user' ],
|
||||
'comment_log_comment' => [ 'JOIN', 'comment_log_comment.comment_id = log_comment_id' ],
|
||||
'actor_log_user' => [ 'JOIN', 'actor_log_user.actor_id = log_actor' ],
|
||||
'logging_actor' => [ 'JOIN', 'actor_id=log_actor' ],
|
||||
],
|
||||
];
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -652,7 +652,6 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
|
|||
"[[original text]] foo",
|
||||
CONTENT_MODEL_WIKITEXT
|
||||
);
|
||||
$id = $page->getId();
|
||||
|
||||
$deleter = $this->getTestSysop()->getUser();
|
||||
|
||||
|
|
@ -666,16 +665,14 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
|
|||
/* unused 2 */ null
|
||||
);
|
||||
$logId = $status->getValue();
|
||||
$actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
|
||||
$commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
|
||||
$this->assertSelect(
|
||||
[ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], /* table */
|
||||
[ 'logging' ] + $commentQuery['tables'], /* table */
|
||||
[
|
||||
'log_type',
|
||||
'log_action',
|
||||
'log_comment' => $commentQuery['fields']['log_comment_text'],
|
||||
'log_user' => $actorQuery['fields']['log_user'],
|
||||
'log_user_text' => $actorQuery['fields']['log_user_text'],
|
||||
'log_actor',
|
||||
'log_namespace',
|
||||
'log_title',
|
||||
],
|
||||
|
|
@ -684,13 +681,12 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
|
|||
'delete',
|
||||
'delete',
|
||||
'testing user 0 deletion',
|
||||
$deleter->getId(),
|
||||
$deleter->getName(),
|
||||
(string)$deleter->getActorId(),
|
||||
(string)$page->getTitle()->getNamespace(),
|
||||
$page->getTitle()->getDBkey(),
|
||||
] ],
|
||||
[],
|
||||
$actorQuery['joins'] + $commentQuery['joins']
|
||||
$commentQuery['joins']
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -703,7 +699,6 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
|
|||
"[[original text]] foo",
|
||||
CONTENT_MODEL_WIKITEXT
|
||||
);
|
||||
$id = $page->getId();
|
||||
|
||||
$user = $this->getTestSysop()->getUser();
|
||||
$errorStack = '';
|
||||
|
|
@ -715,16 +710,14 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
|
|||
/* errorStack */ $errorStack
|
||||
);
|
||||
$logId = $status->getValue();
|
||||
$actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
|
||||
$commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
|
||||
$this->assertSelect(
|
||||
[ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], /* table */
|
||||
[ 'logging' ] + $commentQuery['tables'], /* table */
|
||||
[
|
||||
'log_type',
|
||||
'log_action',
|
||||
'log_comment' => $commentQuery['fields']['log_comment_text'],
|
||||
'log_user' => $actorQuery['fields']['log_user'],
|
||||
'log_user_text' => $actorQuery['fields']['log_user_text'],
|
||||
'log_actor',
|
||||
'log_namespace',
|
||||
'log_title',
|
||||
],
|
||||
|
|
@ -733,13 +726,12 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
|
|||
'delete',
|
||||
'delete',
|
||||
'testing sysop deletion',
|
||||
(string)$user->getId(),
|
||||
$user->getName(),
|
||||
(string)$user->getActorId(),
|
||||
(string)$page->getTitle()->getNamespace(),
|
||||
$page->getTitle()->getDBkey(),
|
||||
] ],
|
||||
[],
|
||||
$actorQuery['joins'] + $commentQuery['joins']
|
||||
$commentQuery['joins']
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -766,16 +758,14 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
|
|||
/* errorStack */ $errorStack
|
||||
);
|
||||
$logId = $status->getValue();
|
||||
$actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
|
||||
$commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
|
||||
$this->assertSelect(
|
||||
[ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], /* table */
|
||||
[ 'logging' ] + $commentQuery['tables'], /* table */
|
||||
[
|
||||
'log_type',
|
||||
'log_action',
|
||||
'log_comment' => $commentQuery['fields']['log_comment_text'],
|
||||
'log_user' => $actorQuery['fields']['log_user'],
|
||||
'log_user_text' => $actorQuery['fields']['log_user_text'],
|
||||
'log_actor',
|
||||
'log_namespace',
|
||||
'log_title',
|
||||
],
|
||||
|
|
@ -784,13 +774,12 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
|
|||
'suppress',
|
||||
'delete',
|
||||
'testing deletion',
|
||||
(string)$user->getId(),
|
||||
$user->getName(),
|
||||
(string)$user->getActorId(),
|
||||
(string)$page->getTitle()->getNamespace(),
|
||||
$page->getTitle()->getDBkey(),
|
||||
] ],
|
||||
[],
|
||||
$actorQuery['joins'] + $commentQuery['joins']
|
||||
$commentQuery['joins']
|
||||
);
|
||||
|
||||
$this->assertNull(
|
||||
|
|
@ -2164,10 +2153,12 @@ more stuff
|
|||
} else {
|
||||
$page = new WikiPage( Title::newFromText( __METHOD__ . '-nonexist' ) );
|
||||
}
|
||||
$user = $this->getTestSysop()->getUserIdentity();
|
||||
$user = $this->getTestSysop()->getUser();
|
||||
$userIdentity = $this->getTestSysop()->getUserIdentity();
|
||||
|
||||
$cascade = false;
|
||||
|
||||
$status = $page->doUpdateRestrictions( $limit, $expiry, $cascade, 'aReason', $user, [] );
|
||||
$status = $page->doUpdateRestrictions( $limit, $expiry, $cascade, 'aReason', $userIdentity, [] );
|
||||
|
||||
$logId = $status->getValue();
|
||||
$allRestrictions = $page->getTitle()->getAllRestrictions();
|
||||
|
|
@ -2181,27 +2172,24 @@ more stuff
|
|||
|
||||
// Make sure the log entry looks good
|
||||
// log_params is not checked here
|
||||
$actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
|
||||
$commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
|
||||
$this->assertSelect(
|
||||
[ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'],
|
||||
[ 'logging' ] + $commentQuery['tables'],
|
||||
[
|
||||
'log_comment' => $commentQuery['fields']['log_comment_text'],
|
||||
'log_user' => $actorQuery['fields']['log_user'],
|
||||
'log_user_text' => $actorQuery['fields']['log_user_text'],
|
||||
'log_actor',
|
||||
'log_namespace',
|
||||
'log_title',
|
||||
],
|
||||
[ 'log_id' => $logId ],
|
||||
[ [
|
||||
'aReason',
|
||||
(string)$user->getId(),
|
||||
$user->getName(),
|
||||
(string)$user->getActorId(),
|
||||
(string)$page->getTitle()->getNamespace(),
|
||||
$page->getTitle()->getDBkey(),
|
||||
] ],
|
||||
[],
|
||||
$actorQuery['joins'] + $commentQuery['joins']
|
||||
$commentQuery['joins']
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue