aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiQueryBlocks.php
diff options
context:
space:
mode:
authorMusikAnimal <musikanimal@gmail.com>2025-01-09 03:03:07 -0500
committerMusikAnimal <musikanimal@gmail.com>2025-01-09 23:45:26 -0500
commit1f99a15b7feadabd31ac1ba7cbee6f9a25ea9fc3 (patch)
tree17e5189a36b3b19876498e4c6c8f2c8c64c78c7d /includes/api/ApiQueryBlocks.php
parent4fe479fc090b3ce2d4f59b172e97afc52844212d (diff)
downloadmediawikicore-1f99a15b7feadabd31ac1ba7cbee6f9a25ea9fc3.tar.gz
mediawikicore-1f99a15b7feadabd31ac1ba7cbee6f9a25ea9fc3.zip
ApiQueryBlocks: add 'parsedreason' prop
This gives feature parity with ApiQueryLogEvents's 'parsedcomment' leprop. Needed by I2c24da2e44630b2bbbf1c041cb3c85cb1a1f7d66 Bug: T383180 Change-Id: Ia0c0c799e0b10b788ab414c9d7bd2fa3f018c3c7
Diffstat (limited to 'includes/api/ApiQueryBlocks.php')
-rw-r--r--includes/api/ApiQueryBlocks.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/includes/api/ApiQueryBlocks.php b/includes/api/ApiQueryBlocks.php
index c1dbece8b76a..749e258c98ec 100644
--- a/includes/api/ApiQueryBlocks.php
+++ b/includes/api/ApiQueryBlocks.php
@@ -27,6 +27,7 @@ use MediaWiki\Block\BlockRestrictionStore;
use MediaWiki\Block\DatabaseBlockStore;
use MediaWiki\Block\HideUserUtils;
use MediaWiki\Block\Restriction\PageRestriction;
+use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MainConfigNames;
use MediaWiki\ParamValidator\TypeDef\UserDef;
@@ -48,6 +49,7 @@ class ApiQueryBlocks extends ApiQueryBase {
private BlockRestrictionStore $blockRestrictionStore;
private CommentStore $commentStore;
private HideUserUtils $hideUserUtils;
+ private CommentFormatter $commentFormatter;
public function __construct(
ApiQuery $query,
@@ -56,7 +58,8 @@ class ApiQueryBlocks extends ApiQueryBase {
BlockActionInfo $blockActionInfo,
BlockRestrictionStore $blockRestrictionStore,
CommentStore $commentStore,
- HideUserUtils $hideUserUtils
+ HideUserUtils $hideUserUtils,
+ CommentFormatter $commentFormatter
) {
parent::__construct( $query, $moduleName, 'bk' );
$this->blockStore = $blockStore;
@@ -64,6 +67,7 @@ class ApiQueryBlocks extends ApiQueryBase {
$this->blockRestrictionStore = $blockRestrictionStore;
$this->commentStore = $commentStore;
$this->hideUserUtils = $hideUserUtils;
+ $this->commentFormatter = $commentFormatter;
}
public function execute() {
@@ -80,6 +84,7 @@ class ApiQueryBlocks extends ApiQueryBase {
$fld_timestamp = isset( $prop['timestamp'] );
$fld_expiry = isset( $prop['expiry'] );
$fld_reason = isset( $prop['reason'] );
+ $fld_parsedreason = isset( $prop['parsedreason'] );
$fld_range = isset( $prop['range'] );
$fld_flags = isset( $prop['flags'] );
$fld_restrictions = isset( $prop['restrictions'] );
@@ -113,7 +118,7 @@ class ApiQueryBlocks extends ApiQueryBase {
$fld_flags );
$this->addFieldsIf( 'bl_sitewide', $fld_restrictions );
- if ( $fld_reason ) {
+ if ( $fld_reason || $fld_parsedreason ) {
$commentQuery = $this->commentStore->getJoin( 'bl_reason' );
$this->addTables( $commentQuery['tables'] );
$this->addFields( $commentQuery['fields'] );
@@ -283,6 +288,11 @@ class ApiQueryBlocks extends ApiQueryBase {
if ( $fld_reason ) {
$block['reason'] = $this->commentStore->getComment( 'bl_reason', $row )->text;
}
+ if ( $fld_parsedreason ) {
+ $block['parsedreason'] = $this->commentFormatter->format(
+ $this->commentStore->getComment( 'bl_reason', $row )->text
+ );
+ }
if ( $fld_range && !$row->bt_auto && $row->bt_range_start !== null ) {
$block['rangestart'] = IPUtils::formatHex( $row->bt_range_start );
$block['rangeend'] = IPUtils::formatHex( $row->bt_range_end );
@@ -428,6 +438,7 @@ class ApiQueryBlocks extends ApiQueryBase {
'timestamp',
'expiry',
'reason',
+ 'parsedreason',
'range',
'flags',
'restrictions',