aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiQueryBlocks.php
diff options
context:
space:
mode:
authorTim Starling <tstarling@wikimedia.org>2023-11-15 17:09:27 +1100
committerMusikAnimal <musikanimal@gmail.com>2023-12-05 13:25:54 -0500
commit60911137ef7e445b93ed345e0e0b066db272e322 (patch)
treecb6e97104c00f88746343c16520388ce015ec1cb /includes/api/ApiQueryBlocks.php
parente48ef8decf82be66a618d444e763d2c00847ae2c (diff)
downloadmediawikicore-60911137ef7e445b93ed345e0e0b066db272e322.tar.gz
mediawikicore-60911137ef7e445b93ed345e0e0b066db272e322.zip
Special:BlockList: Improve display of hidden users
With multiblocks the user might be hidden even if bl_deleted=0 in the block row being formatted. So: * Add a subquery with a second block_target/block table which determines whether the user is deleted. * When formatting each row, redact the name if it is deleted and the authority does not have permission to see it. * Add a parameter to show which block is the one responsible for deleting the user. * Similarly add a subquery in ApiQueryBlocks. Change-Id: Id9900397618e1f626802ada6fe4ee4ad10f32495
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 b9db1ba4a08e..5c7145502183 100644
--- a/includes/api/ApiQueryBlocks.php
+++ b/includes/api/ApiQueryBlocks.php
@@ -23,6 +23,7 @@
use MediaWiki\Block\BlockActionInfo;
use MediaWiki\Block\BlockRestrictionStore;
use MediaWiki\Block\DatabaseBlockStore;
+use MediaWiki\Block\HideUserUtils;
use MediaWiki\Block\Restriction\PageRestriction;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\MainConfigNames;
@@ -44,6 +45,7 @@ class ApiQueryBlocks extends ApiQueryBase {
private BlockActionInfo $blockActionInfo;
private BlockRestrictionStore $blockRestrictionStore;
private CommentStore $commentStore;
+ private HideUserUtils $hideUserUtils;
/** @var int */
private $blockTargetReadStage;
@@ -55,6 +57,7 @@ class ApiQueryBlocks extends ApiQueryBase {
* @param BlockActionInfo $blockActionInfo
* @param BlockRestrictionStore $blockRestrictionStore
* @param CommentStore $commentStore
+ * @param HideUserUtils $hideUserUtils
*/
public function __construct(
ApiQuery $query,
@@ -62,13 +65,15 @@ class ApiQueryBlocks extends ApiQueryBase {
DatabaseBlockStore $blockStore,
BlockActionInfo $blockActionInfo,
BlockRestrictionStore $blockRestrictionStore,
- CommentStore $commentStore
+ CommentStore $commentStore,
+ HideUserUtils $hideUserUtils
) {
parent::__construct( $query, $moduleName, 'bk' );
$this->blockStore = $blockStore;
$this->blockActionInfo = $blockActionInfo;
$this->blockRestrictionStore = $blockRestrictionStore;
$this->commentStore = $commentStore;
+ $this->hideUserUtils = $hideUserUtils;
$this->blockTargetReadStage = $this->getConfig()
->get( MainConfigNames::BlockTargetMigrationStage ) & SCHEMA_COMPAT_READ_MASK;
}
@@ -264,7 +269,13 @@ class ApiQueryBlocks extends ApiQueryBase {
}
if ( !$this->getAuthority()->isAllowed( 'hideuser' ) ) {
- $this->addWhereFld( $bl_deleted, 0 );
+ if ( $this->blockTargetReadStage === SCHEMA_COMPAT_READ_OLD ) {
+ $this->addWhereFld( $bl_deleted, 0 );
+ } else {
+ $this->addWhere(
+ $this->hideUserUtils->getExpression( $db, 'block_target.bt_user' )
+ );
+ }
}
// Filter out expired rows