diff options
author | MusikAnimal <musikanimal@gmail.com> | 2025-01-09 03:03:07 -0500 |
---|---|---|
committer | MusikAnimal <musikanimal@gmail.com> | 2025-01-09 23:45:26 -0500 |
commit | 1f99a15b7feadabd31ac1ba7cbee6f9a25ea9fc3 (patch) | |
tree | 17e5189a36b3b19876498e4c6c8f2c8c64c78c7d /includes | |
parent | 4fe479fc090b3ce2d4f59b172e97afc52844212d (diff) | |
download | mediawikicore-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')
-rw-r--r-- | includes/api/ApiQuery.php | 1 | ||||
-rw-r--r-- | includes/api/ApiQueryBlocks.php | 15 | ||||
-rw-r--r-- | includes/api/i18n/en.json | 1 | ||||
-rw-r--r-- | includes/api/i18n/qqq.json | 1 |
4 files changed, 16 insertions, 2 deletions
diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index e4535eec1496..830911b85d7f 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -340,6 +340,7 @@ class ApiQuery extends ApiBase { 'BlockRestrictionStore', 'CommentStore', 'HideUserUtils', + 'CommentFormatter', ], ], 'categorymembers' => [ 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', diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json index c4d56ef85d42..7388de42f8f1 100644 --- a/includes/api/i18n/en.json +++ b/includes/api/i18n/en.json @@ -725,6 +725,7 @@ "apihelp-query+blocks-paramvalue-prop-timestamp": "Adds the timestamp of when the block was given.", "apihelp-query+blocks-paramvalue-prop-expiry": "Adds the timestamp of when the block expires.", "apihelp-query+blocks-paramvalue-prop-reason": "Adds the reason given for the block.", + "apihelp-query+blocks-paramvalue-prop-parsedreason": "Adds the parsed reason given for the block.", "apihelp-query+blocks-paramvalue-prop-range": "Adds the range of IP addresses affected by the block.", "apihelp-query+blocks-paramvalue-prop-flags": "Tags the ban with (autoblock, anononly, etc.).", "apihelp-query+blocks-paramvalue-prop-restrictions": "Adds the partial block restrictions if the block is not sitewide.", diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json index d2747f5f48d2..01d0b219926f 100644 --- a/includes/api/i18n/qqq.json +++ b/includes/api/i18n/qqq.json @@ -694,6 +694,7 @@ "apihelp-query+blocks-paramvalue-prop-timestamp": "{{doc-apihelp-paramvalue|query+blocks|prop|timestamp}}", "apihelp-query+blocks-paramvalue-prop-expiry": "{{doc-apihelp-paramvalue|query+blocks|prop|expiry}}", "apihelp-query+blocks-paramvalue-prop-reason": "{{doc-apihelp-paramvalue|query+blocks|prop|reason}}", + "apihelp-query+blocks-paramvalue-prop-parsedreason": "{{doc-apihelp-paramvalue|query+blocks|prop|parsedreason}}", "apihelp-query+blocks-paramvalue-prop-range": "{{doc-apihelp-paramvalue|query+blocks|prop|range}}", "apihelp-query+blocks-paramvalue-prop-flags": "{{doc-apihelp-paramvalue|query+blocks|prop|flags}}", "apihelp-query+blocks-paramvalue-prop-restrictions": "{{doc-apihelp-paramvalue|query+blocks|prop|restrictions}}", |