X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiQueryAllUsers.php;h=0ea6af3247d6eaa0e3e5f9a4f611f0705c638757;hp=59e92e153870faa94bc9200268e2917ad7c2534c;hb=9d31e46d0f4dc6d68ad38b09816bea2b447f8b50;hpb=d1044768f67a27227031dd43d0c8850bc465b413 diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index 59e92e1538..0ea6af3247 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -20,12 +20,16 @@ * @file */ +use MediaWiki\Block\DatabaseBlock; + /** * Query module to enumerate all registered users. * * @ingroup API */ class ApiQueryAllUsers extends ApiQueryBase { + use ApiQueryBlockInfoTrait; + public function __construct( ApiQuery $query, $moduleName ) { parent::__construct( $query, $moduleName, 'au' ); } @@ -41,8 +45,6 @@ class ApiQueryAllUsers extends ApiQueryBase { } public function execute() { - global $wgActorTableSchemaMigrationStage; - $params = $this->extractRequestParams(); $activeUserDays = $this->getConfig()->get( 'ActiveUserDays' ); @@ -90,7 +92,8 @@ class ApiQueryAllUsers extends ApiQueryBase { if ( !is_null( $params['rights'] ) && count( $params['rights'] ) ) { $groups = []; foreach ( $params['rights'] as $r ) { - $groups = array_merge( $groups, User::getGroupsWithPermission( $r ) ); + $groups = array_merge( $groups, $this->getPermissionManager() + ->getGroupsWithPermission( $r ) ); } // no group with the given right(s) exists, no need for a query @@ -154,7 +157,7 @@ class ApiQueryAllUsers extends ApiQueryBase { $this->addWhere( 'user_editcount > 0' ); } - $this->showHiddenUsersAddBlockInfo( $fld_blockinfo ); + $this->addBlockInfoToQuery( $fld_blockinfo ); if ( $fld_groups || $fld_rights ) { $this->addFields( [ 'groups' => @@ -180,22 +183,17 @@ class ApiQueryAllUsers extends ApiQueryBase { ] ] ); // Actually count the actions using a subquery (T66505 and T66507) - $tables = [ 'recentchanges' ]; - $joins = []; - if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_OLD ) { - $userCond = 'rc_user_text = user_name'; - } else { - $tables[] = 'actor'; - $joins['actor'] = [ 'JOIN', 'rc_actor = actor_id' ]; - $userCond = 'actor_user = user_id'; - } + $tables = [ 'recentchanges', 'actor' ]; + $joins = [ + 'actor' => [ 'JOIN', 'rc_actor = actor_id' ], + ]; $timestamp = $db->timestamp( wfTimestamp( TS_UNIX ) - $activeUserSeconds ); $this->addFields( [ 'recentactions' => '(' . $db->selectSQLText( $tables, 'COUNT(*)', [ - $userCond, + 'actor_user = user_id', '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 ), @@ -269,13 +267,8 @@ class ApiQueryAllUsers extends ApiQueryBase { ); } - if ( $fld_blockinfo && !is_null( $row->ipb_by_text ) ) { - $data['blockid'] = (int)$row->ipb_id; - $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( 'ipb_reason', $row )->text; - $data['blockexpiry'] = $row->ipb_expiry; + if ( $fld_blockinfo && !is_null( $row->ipb_id ) ) { + $data += $this->getBlockDetails( DatabaseBlock::newFromRow( $row ) ); } if ( $row->ipb_deleted ) { $data['hidden'] = true; @@ -312,7 +305,7 @@ class ApiQueryAllUsers extends ApiQueryBase { } if ( $fld_rights ) { - $data['rights'] = User::getGroupPermissions( $groups ); + $data['rights'] = $this->getPermissionManager()->getGroupPermissions( $groups ); ApiResult::setIndexedTagName( $data['rights'], 'r' ); ApiResult::setArrayType( $data['rights'], 'array' ); } @@ -355,7 +348,7 @@ class ApiQueryAllUsers extends ApiQueryBase { ApiBase::PARAM_ISMULTI => true, ], 'rights' => [ - ApiBase::PARAM_TYPE => User::getAllRights(), + ApiBase::PARAM_TYPE => $this->getPermissionManager()->getAllPermissions(), ApiBase::PARAM_ISMULTI => true, ], 'prop' => [