Merge "generatePhpCharToUpperMappings: Die if fopen fails"
[lhc/web/wiklou.git] / includes / api / ApiQueryAllUsers.php
index a7d4fb9..0ea6af3 100644 (file)
  * @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' );
        }
@@ -153,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' =>
@@ -263,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;