X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryAllUsers.php;h=9652f810f74d2e646c288c9080c2ac68d165df16;hb=d2db6c2f128d45f6077fb65cec2ccdf4dab4a272;hp=65a4b321278147c88e0be0698faf5ff4db52fa94;hpb=526341516a91502ac7cfd2e5590e7432b3f50c5d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index 65a4b32127..9652f810f7 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -41,11 +41,13 @@ class ApiQueryAllUsers extends ApiQueryBase { } public function execute() { + global $wgActorTableSchemaMigrationStage; + $params = $this->extractRequestParams(); $activeUserDays = $this->getConfig()->get( 'ActiveUserDays' ); $db = $this->getDB(); - $commentStore = new CommentStore( 'ipb_reason' ); + $commentStore = CommentStore::getStore(); $prop = $params['prop']; if ( !is_null( $prop ) ) { @@ -178,17 +180,36 @@ class ApiQueryAllUsers extends ApiQueryBase { ] ] ); // Actually count the actions using a subquery (T66505 and T66507) + $tables = [ 'recentchanges' ]; + $joins = []; + if ( $wgActorTableSchemaMigrationStage === MIGRATION_OLD ) { + $userCond = 'rc_user_text = user_name'; + } else { + $tables[] = 'actor'; + $joins['actor'] = [ + $wgActorTableSchemaMigrationStage === MIGRATION_NEW ? 'JOIN' : 'LEFT JOIN', + 'rc_actor = actor_id' + ]; + if ( $wgActorTableSchemaMigrationStage === MIGRATION_NEW ) { + $userCond = 'actor_user = user_id'; + } else { + $userCond = 'actor_user = user_id OR (rc_actor = 0 AND rc_user_text = user_name)'; + } + } $timestamp = $db->timestamp( wfTimestamp( TS_UNIX ) - $activeUserSeconds ); $this->addFields( [ 'recentactions' => '(' . $db->selectSQLText( - 'recentchanges', + $tables, 'COUNT(*)', [ - 'rc_user_text = user_name', + $userCond, 'rc_type != ' . $db->addQuotes( RC_EXTERNAL ), // no wikidata 'rc_log_type IS NULL OR rc_log_type != ' . $db->addQuotes( 'newusers' ), 'rc_timestamp >= ' . $db->addQuotes( $timestamp ), - ] + ], + __METHOD__, + [], + $joins ) . ')' ] ); } @@ -260,7 +281,7 @@ class ApiQueryAllUsers extends ApiQueryBase { $data['blockedby'] = $row->ipb_by_text; $data['blockedbyid'] = (int)$row->ipb_by; $data['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $row->ipb_timestamp ); - $data['blockreason'] = $commentStore->getComment( $row )->text; + $data['blockreason'] = $commentStore->getComment( 'ipb_reason', $row )->text; $data['blockexpiry'] = $row->ipb_expiry; } if ( $row->ipb_deleted ) {