From 5aa9ba58ead7cd9ad101e59357ff83d84ebec1a1 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 18 Jul 2019 17:04:06 +0100 Subject: [PATCH] API: Always select rc_user from database (regardless of rcprop=user) Bug: T228425 Change-Id: I1b6f684c8289282326da0e326b90fcf8ff87d71e --- includes/api/ApiQueryRecentChanges.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index 8ae1b668b4..f5952e3c18 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -312,12 +312,6 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { /* Add fields to our query if they are specified as a needed parameter. */ $this->addFieldsIf( [ 'rc_this_oldid', 'rc_last_oldid' ], $this->fld_ids ); - if ( $this->fld_user || $this->fld_userid ) { - $actorQuery = ActorMigration::newMigration()->getJoin( 'rc_user' ); - $this->addTables( $actorQuery['tables'] ); - $this->addFields( $actorQuery['fields'] ); - $this->addJoinConds( $actorQuery['joins'] ); - } $this->addFieldsIf( [ 'rc_minor', 'rc_type', 'rc_bot' ], $this->fld_flags ); $this->addFieldsIf( [ 'rc_old_len', 'rc_new_len' ], $this->fld_sizes ); $this->addFieldsIf( [ 'rc_patrolled', 'rc_log_type' ], $this->fld_patrolled ); @@ -405,6 +399,14 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $this->addJoinConds( $commentQuery['joins'] ); } + if ( $this->fld_user || $this->fld_userid || !is_null( $this->token ) ) { + // Token needs rc_user for RecentChange::newFromRow/User::newFromAnyId (T228425) + $actorQuery = ActorMigration::newMigration()->getJoin( 'rc_user' ); + $this->addTables( $actorQuery['tables'] ); + $this->addFields( $actorQuery['fields'] ); + $this->addJoinConds( $actorQuery['joins'] ); + } + $this->addOption( 'LIMIT', $params['limit'] + 1 ); $hookData = []; -- 2.20.1