X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryUserInfo.php;h=ba7280da105c0be0c589664dfe644e3194801619;hb=1bd43b1bffffc3720e1ef743d802e88fdf849b0f;hp=59e0524ad96157e83b9987e5666f0eed0553b442;hpb=4a958273c1ecfe5d13492fc4b469aeba9877e00f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryUserInfo.php b/includes/api/ApiQueryUserInfo.php index 59e0524ad9..ba7280da10 100644 --- a/includes/api/ApiQueryUserInfo.php +++ b/includes/api/ApiQueryUserInfo.php @@ -20,6 +20,7 @@ * @file */ +use MediaWiki\Block\AbstractBlock; use MediaWiki\MediaWikiServices; /** @@ -29,6 +30,8 @@ use MediaWiki\MediaWikiServices; */ class ApiQueryUserInfo extends ApiQueryBase { + use ApiBlockInfoTrait; + const WL_UNREAD_LIMIT = 1000; private $params = []; @@ -52,29 +55,22 @@ class ApiQueryUserInfo extends ApiQueryBase { /** * Get basic info about a given block - * @param Block $block - * @return array Array containing several keys: - * - blockid - ID of the block - * - blockedby - username of the blocker - * - blockedbyid - user ID of the blocker - * - blockreason - reason provided for the block - * - blockedtimestamp - timestamp for when the block was placed/modified - * - blockexpiry - expiry time of the block - * - systemblocktype - system block type, if any + * + * @deprecated since 1.34 Use ApiBlockInfoTrait::getBlockDetails() instead. + * @param AbstractBlock $block + * @return array See ApiBlockInfoTrait::getBlockDetails */ - public static function getBlockInfo( Block $block ) { - $vals = []; - $vals['blockid'] = $block->getId(); - $vals['blockedby'] = $block->getByName(); - $vals['blockedbyid'] = $block->getBy(); - $vals['blockreason'] = $block->getReason(); - $vals['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $block->getTimestamp() ); - $vals['blockexpiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' ); - $vals['blockpartial'] = !$block->isSitewide(); - if ( $block->getSystemBlockType() !== null ) { - $vals['systemblocktype'] = $block->getSystemBlockType(); - } - return $vals; + public static function getBlockInfo( AbstractBlock $block ) { + wfDeprecated( __METHOD__, '1.34' ); + + // Hack to access a private method from a trait: + $dummy = new class { + use ApiBlockInfoTrait { + getBlockDetails as public; + } + }; + + return $dummy->getBlockDetails( $block ); } /** @@ -126,8 +122,11 @@ class ApiQueryUserInfo extends ApiQueryBase { $vals['anon'] = true; } - if ( isset( $this->prop['blockinfo'] ) && $user->isBlocked() ) { - $vals = array_merge( $vals, self::getBlockInfo( $user->getBlock() ) ); + if ( isset( $this->prop['blockinfo'] ) ) { + $block = $user->getBlock(); + if ( $block ) { + $vals = array_merge( $vals, $this->getBlockDetails( $block ) ); + } } if ( isset( $this->prop['hasmsg'] ) ) {