Page MenuHomePhabricator

Special:MassGlobalBlock: RuntimeException: Can't reblock a user with multiple blocks already present
Closed, ResolvedPublic2 Estimated Story PointsBUG REPORT

Description

What is the problem?

Attempting to use Special:MassGlobalBlock on a target which already has more than one block shows the exception:

[d109d5c52ae6f83a03737b03] /wiki/Special:MassGlobalBlock RuntimeException: Can\'t reblock a user with multiple blocks already present. Update calling code for multiblocks, providing a specific block to update.

Backtrace:

from /var/www/html/w/includes/block/BlockUser.php(628)
#0 /var/www/html/w/includes/block/BlockUser.php(566): MediaWiki\Block\BlockUser->placeBlockInternal()
#1 /var/www/html/w/includes/block/BlockUser.php(491): MediaWiki\Block\BlockUser->placeBlockUnsafe()
#2 /var/www/html/w/extensions/GlobalBlocking/includes/Special/SpecialMassGlobalBlock.php(553): MediaWiki\Block\BlockUser->placeBlock()
#3 /var/www/html/w/extensions/GlobalBlocking/includes/Special/SpecialMassGlobalBlock.php(117): MediaWiki\Extension\GlobalBlocking\Special\SpecialMassGlobalBlock->performGlobalBlockChanges()
#4 /var/www/html/w/includes/specialpage/SpecialPage.php(729): MediaWiki\Extension\GlobalBlocking\Special\SpecialMassGlobalBlock->execute()
#5 /var/www/html/w/includes/specialpage/SpecialPageFactory.php(1737): MediaWiki\SpecialPage\SpecialPage->run()
#6 /var/www/html/w/includes/actions/ActionEntryPoint.php(503): MediaWiki\SpecialPage\SpecialPageFactory->executePath()
#7 /var/www/html/w/includes/actions/ActionEntryPoint.php(145): MediaWiki\Actions\ActionEntryPoint->performRequest()
#8 /var/www/html/w/includes/MediaWikiEntryPoint.php(202): MediaWiki\Actions\ActionEntryPoint->execute()
#9 /var/www/html/w/index.php(58): MediaWiki\MediaWikiEntryPoint->run()
#10 {main}

Special:GlobalBlock does not exhibit the same behaviour. After submit it just states Blocking the user locally failed as the given user already is blocked on this wiki. I guess MassGlobalBlock should do the same for each already blocked user.

Steps to reproduce problem
  1. On a wiki with GlobalBlocking, Codex Special:Block and Multiblocks enabled ($wgUseCodexSpecialBlock = true; $wgEnableMultiBlocks = true;)
  2. Use Special:Block to create two blocks against the same user or IP
  3. Go to Special:MassGlobalBlock
  4. Enter the name of the user/IP from step 2 and press Search
  5. Choose an expiry time
  6. Select "Also block the given user locally on this wiki"
  7. Submit

Expected behaviour: User/IP is blocked globally. There is a message saying that the local block failed to be created.
Observed behaviour: Above exception.

Environment

Wiki(s): local docker MediaWiki 1.44.0-alpha (9669d77) 08:30, 3 March 2025. GlobalBlocking – (ac947c7) 07:27, 3 March 2025.

Derived Requirement

Ensure that Special:MassGlobalBlock properly handles users/IPs with multiple existing local blocks by:

  • Preventing the RuntimeException: Can't reblock a user with multiple blocks already present.
  • Displaying a message stating that the local block could not be created when the user/IP is already blocked.
  • Successfully applying the global block while handling local block failures gracefully.
Test Steps

Test Case 1: Verify that Special:MassGlobalBlock does not throw a RuntimeException when blocking a user with multiple existing local blocks

  1. On a wiki with GlobalBlocking, Codex Special:Block, and Multiblocks enabled, navigate to Special:Block.
  2. Enter a target user/IP and apply a first block.
  3. Apply a second block on the same user/IP.
  4. Navigate to Special:MassGlobalBlock.
  5. Enter the same user/IP in the search field and press Search.
  6. Choose an expiry time and select "Also block the given user locally on this wiki."
  7. Click Submit.
  8. ✅❓❌⬜ AC1: Confirm that global block is successfully applied without issues and RuntimeException is not thrown**.
  9. ✅❓❌⬜ AC2: Confirm that a message states that the local block could not be created because the user/IP is already blocked.

QA Results - Test Wiki

ACStatusDetails
1T387730#10654041
2T387730#10654041

Event Timeline

Change #1124566 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/extensions/GlobalBlocking@master] MassGlobalBlock: don't locally reblock

https://gerrit.wikimedia.org/r/1124566

Change #1124566 merged by jenkins-bot:

[mediawiki/extensions/GlobalBlocking@master] Update BlockUser::placeBlock() calls for multiblocks

https://gerrit.wikimedia.org/r/1124566

@tstarling Please review AC2, thanks!

Test Result - Local

Status: ❓Need More Info
Environment: Local: Mediawiki- 1.44.0-alpha (af413e5) 13:51, 19 March 2025; GlobalBlocking: – (06f2cf5)18:13, 17 March 2025
OS: macOS Sequoia 15.4
Browser: Chrome 134
Device: MBA
Emulated Device: NA

Test Artifact(s):

Test Steps

Test Case 1: Verify that Special:MassGlobalBlock does not throw a RuntimeException when blocking a user with multiple existing local blocks

  1. On a wiki with GlobalBlocking, Codex Special:Block, and Multiblocks enabled, navigate to Special:Block.
  2. Enter a target user/IP and apply a first block.
  3. Apply a second block on the same user/IP.
  4. Navigate to Special:MassGlobalBlock.
  5. Enter the same user/IP in the search field and press Search.
  6. Choose an expiry time and select "Also block the given user locally on this wiki."
  7. Click Submit.
  8. AC1: Confirm that global block is successfully applied without issues and RuntimeException is not thrown**.

gif

2025-03-19_11-52-27.mp4.gif (1×1 px, 2 MB)

  1. AC2: Confirm that a message states that the local block could not be created because the user/IP is already blocked.

I don't see the message local block could not be created because the user/IP is already blocked after I clicked submit in Special:MassGlobalBlock but I do see 2 messages saying "Successfully globally blocked Localplayerone" as seen in the above gif
See AC1

  1. AC2: Confirm that a message states that the local block could not be created because the user/IP is already blocked.

I don't see the message local block could not be created because the user/IP is already blocked after I clicked submit in Special:MassGlobalBlock but I do see 2 messages saying "Successfully globally blocked Localplayerone" as seen in the above gif

This is correct per the comment by Dreamy Jazz on the gerrit change:

I've asked Stewards using the Discord channel we have with them, and they would prefer that a new local block is added if MultiBlocks is enabled and the current behaviour is kept if MultiBlocks is not enabled.

This is because a steward said that basically every global block comes with an associated local block, and when this doesn't happen it causes headaches later. Therefore, any existing block on metawiki (even if not sitewide) would cause their local block to fail and then an extra step of visiting Special:Block to add a new local sitewide block with the same parameters would be performed.

In summary, AC2 asks for an error message, but users requested that the local block should succeed instead.