Merge "StringUtils: Add a utility for checking if a string is a valid regex"
[lhc/web/wiklou.git] / includes / api / ApiQueryUsers.php
index 66d8db4..0171a37 100644 (file)
  * @file
  */
 
+use MediaWiki\Block\DatabaseBlock;
+
 /**
  * Query module to get information about a list of users
  *
  * @ingroup API
  */
 class ApiQueryUsers extends ApiQueryBase {
+       use ApiQueryBlockInfoTrait;
 
        private $tokenFunctions, $prop;
 
@@ -150,7 +153,7 @@ class ApiQueryUsers extends ApiQueryBase {
                                $this->addWhereFld( 'user_id', $userids );
                        }
 
-                       $this->showHiddenUsersAddBlockInfo( isset( $this->prop['blockinfo'] ) );
+                       $this->addBlockInfoToQuery( isset( $this->prop['blockinfo'] ) );
 
                        $data = [];
                        $res = $this->select( __METHOD__ );
@@ -225,19 +228,14 @@ class ApiQueryUsers extends ApiQueryBase {
                                }
 
                                if ( isset( $this->prop['rights'] ) ) {
-                                       $data[$key]['rights'] = $user->getRights();
+                                       $data[$key]['rights'] = $this->getPermissionManager()
+                                               ->getUserPermissions( $user );
                                }
                                if ( $row->ipb_deleted ) {
                                        $data[$key]['hidden'] = true;
                                }
                                if ( isset( $this->prop['blockinfo'] ) && !is_null( $row->ipb_by_text ) ) {
-                                       $data[$key]['blockid'] = (int)$row->ipb_id;
-                                       $data[$key]['blockedby'] = $row->ipb_by_text;
-                                       $data[$key]['blockedbyid'] = (int)$row->ipb_by;
-                                       $data[$key]['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $row->ipb_timestamp );
-                                       $data[$key]['blockreason'] = $commentStore->getComment( 'ipb_reason', $row )
-                                               ->text;
-                                       $data[$key]['blockexpiry'] = $row->ipb_expiry;
+                                       $data[$key] += $this->getBlockDetails( DatabaseBlock::newFromRow( $row ) );
                                }
 
                                if ( isset( $this->prop['emailable'] ) ) {
@@ -331,8 +329,8 @@ class ApiQueryUsers extends ApiQueryBase {
                                }
                        }
 
-                       $fit = $result->addValue( [ 'query', $this->getModuleName() ],
-                               null, $data[$u] );
+                       // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
+                       $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $data[$u] );
                        if ( !$fit ) {
                                if ( $useNames ) {
                                        $this->setContinueEnumParameter( 'users',