* @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' );
}
}
public function execute() {
- global $wgActorTableSchemaMigrationStage;
-
$params = $this->extractRequestParams();
$activeUserDays = $this->getConfig()->get( 'ActiveUserDays' );
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
$this->addWhere( 'user_editcount > 0' );
}
- $this->showHiddenUsersAddBlockInfo( $fld_blockinfo );
+ $this->addBlockInfoToQuery( $fld_blockinfo );
if ( $fld_groups || $fld_rights ) {
$this->addFields( [ 'groups' =>
] ] );
// 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 ),
);
}
- 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;
}
if ( $params['activeusers'] ) {
$data['recentactions'] = (int)$row->recentactions;
- // @todo 'recenteditcount' is set for BC, remove in 1.25
- $data['recenteditcount'] = $data['recentactions'];
}
if ( $fld_registration ) {
$data['registration'] = $row->user_registration ?
}
if ( $fld_rights ) {
- $data['rights'] = User::getGroupPermissions( $groups );
+ $data['rights'] = $this->getPermissionManager()->getGroupPermissions( $groups );
ApiResult::setIndexedTagName( $data['rights'], 'r' );
ApiResult::setArrayType( $data['rights'], 'array' );
}
ApiBase::PARAM_ISMULTI => true,
],
'rights' => [
- ApiBase::PARAM_TYPE => User::getAllRights(),
+ ApiBase::PARAM_TYPE => $this->getPermissionManager()->getAllPermissions(),
ApiBase::PARAM_ISMULTI => true,
],
'prop' => [
protected function getExamplesMessages() {
return [
'action=query&list=allusers&aufrom=Y'
- => 'apihelp-query+allusers-example-Y',
+ => 'apihelp-query+allusers-example-y',
];
}