Page MenuHomePhabricator

/wiki/Special:GlobalBlock Wikimedia\Assert\PreconditionException: Expected MediaWiki\User\UserIdentityValue to belong to the local wiki, but it belongs to 'commonswiki'
Closed, ResolvedPublic1 Estimated Story PointsBUG REPORT

Description

What is the problem?

When creating a global block with autoblock enabled on the non-central wiki and the user you are trying to block has several entries in the cuci_user table, I get the below exception:

[cdc2d3f26403275f14dd3384] /wiki/Special:GlobalBlock Wikimedia\Assert\PreconditionException: Expected MediaWiki\User\UserIdentityValue to belong to the local wiki, but it belongs to 'commonswiki'

Backtrace:

from /var/www/html/w/includes/dao/WikiAwareEntityTrait.php(59)
#0 /var/www/html/w/includes/user/UserIdentityValue.php(129): MediaWiki\User\UserIdentityValue->assertWiki()
#1 /var/www/html/w/extensions/CheckUser/src/HookHandler/GlobalBlockingHandler.php(150): MediaWiki\User\UserIdentityValue->getId()
#2 /var/www/html/w/extensions/CheckUser/src/HookHandler/GlobalBlockingHandler.php(103): MediaWiki\CheckUser\HookHandler\GlobalBlockingHandler->fetchIPAddressesFromLocalWiki()
#3 /var/www/html/w/includes/HookContainer/HookContainer.php(159): MediaWiki\CheckUser\HookHandler\GlobalBlockingHandler->onGlobalBlockingGetRetroactiveAutoblockIPs()
#4 /var/www/html/w/extensions/GlobalBlocking/includes/Hooks/HookRunner.php(20): MediaWiki\HookContainer\HookContainer->run()
#5 /var/www/html/w/extensions/GlobalBlocking/includes/Services/GlobalBlockManager.php(247): MediaWiki\Extension\GlobalBlocking\Hooks\HookRunner->onGlobalBlockingGetRetroactiveAutoblockIPs()
#6 /var/www/html/w/extensions/GlobalBlocking/includes/Services/GlobalBlockManager.php(125): MediaWiki\Extension\GlobalBlocking\Services\GlobalBlockManager->insertBlockAfterChecks()
#7 /var/www/html/w/extensions/GlobalBlocking/includes/Services/GlobalBlockManager.php(287): MediaWiki\Extension\GlobalBlocking\Services\GlobalBlockManager->insertBlock()
#8 /var/www/html/w/extensions/GlobalBlocking/includes/Special/SpecialGlobalBlock.php(348): MediaWiki\Extension\GlobalBlocking\Services\GlobalBlockManager->block()
#9 [internal function]: MediaWiki\Extension\GlobalBlocking\Special\SpecialGlobalBlock->onSubmit()
#10 /var/www/html/w/includes/htmlform/HTMLForm.php(822): call_user_func()
#11 /var/www/html/w/includes/htmlform/HTMLForm.php(703): MediaWiki\HTMLForm\HTMLForm->trySubmit()
#12 /var/www/html/w/includes/htmlform/HTMLForm.php(719): MediaWiki\HTMLForm\HTMLForm->tryAuthorizedSubmit()
#13 /var/www/html/w/includes/specialpage/FormSpecialPage.php(241): MediaWiki\HTMLForm\HTMLForm->show()
#14 /var/www/html/w/extensions/GlobalBlocking/includes/Special/SpecialGlobalBlock.php(76): MediaWiki\SpecialPage\FormSpecialPage->execute()
#15 /var/www/html/w/includes/specialpage/SpecialPage.php(728): MediaWiki\Extension\GlobalBlocking\Special\SpecialGlobalBlock->execute()
#16 /var/www/html/w/includes/specialpage/SpecialPageFactory.php(1726): MediaWiki\SpecialPage\SpecialPage->run()
#17 /var/www/html/w/includes/actions/ActionEntryPoint.php(504): MediaWiki\SpecialPage\SpecialPageFactory->executePath()
#18 /var/www/html/w/includes/actions/ActionEntryPoint.php(146): MediaWiki\Actions\ActionEntryPoint->performRequest()
#19 /var/www/html/w/includes/MediaWikiEntryPoint.php(200): MediaWiki\Actions\ActionEntryPoint->execute()
#20 /var/www/html/w/index.php(58): MediaWiki\MediaWikiEntryPoint->run()
#21 {main}

I can successfully block the same user from my central wiki.

Steps to reproduce problem
  1. Setup a wiki with several wikis connected with CentralAuth, GlobalBlocking and CheckUser and config $wgGlobalBlockingEnableAutoblocks = true; $wgAutoCreateTempUser['enabled'] = true;
  2. Login as a user and make edits on several different wikis
  3. Login as a steward on one of the wikis which is not the central wiki (i.e. not the value of $wgCentralAuthLoginWiki)
  4. Go to Special:GlobalBlock, enter the user from step 2, check "Automatically globally block the last IP address..." (it is by default) and submit

Expected behaviour: Global block is created.
Observed behaviour: Above exception.

Environment

Wiki(s): local docker GlobalBlocking – (ce531e3) 14:02, 22 October 2024. CheckUser 2.5 (6e55823) 10:18, 24 October 2024.

Event Timeline

Dreamy_Jazz set the point value for this task to 2.EditedOct 24 2024, 2:44 PM
Dreamy_Jazz subscribed.

Thanks for finding / filing this.

I suspect that this will cause issues when trying to globally block temporary accounts with global autoblocking enabled, as they are not currently created on metawiki (so it will be as if metawiki isn't one of the wikis in the list of wikis where accounts are auto-created on account creation).

As such, moving into the current sprint.

Change #1083147 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/CheckUser@master] Specify wiki ID to ::getId call in GlobalBlockingHandler

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

Change #1083147 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] Specify wiki ID to ::getId call in GlobalBlockingHandler

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

Change #1083772 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/CheckUser@wmf/1.43.0-wmf.28] Specify wiki ID to ::getId call in GlobalBlockingHandler

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

Change #1083772 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@wmf/1.43.0-wmf.28] Specify wiki ID to ::getId call in GlobalBlockingHandler

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

Mentioned in SAL (#wikimedia-operations) [2024-10-28T11:23:11Z] <dreamyjazz@deploy2002> Started scap sync-world: Backport for [[gerrit:1083772|Specify wiki ID to ::getId call in GlobalBlockingHandler (T378085)]]

Mentioned in SAL (#wikimedia-operations) [2024-10-28T11:25:27Z] <dreamyjazz@deploy2002> dreamyjazz: Backport for [[gerrit:1083772|Specify wiki ID to ::getId call in GlobalBlockingHandler (T378085)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2024-10-28T11:30:55Z] <dreamyjazz@deploy2002> Finished scap sync-world: Backport for [[gerrit:1083772|Specify wiki ID to ::getId call in GlobalBlockingHandler (T378085)]] (duration: 07m 44s)

I cannot reproduce the bug.

I have tried autoblocking various users with different numbers of entries in the cuci_user table from various wikis on my local wiki farm. I did not see any exceptions.

There are circumstances where autoblocks are not created when arguably they could be, because a user does not exist locally (see T378685).

Change #1116542 had a related patch set uploaded (by Agent Isai; author: Dreamy Jazz):

[mediawiki/extensions/CheckUser@REL1_43] Specify wiki ID to ::getId call in GlobalBlockingHandler

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

Change #1116542 abandoned by Agent Isai:

[mediawiki/extensions/CheckUser@REL1_43] Specify wiki ID to ::getId call in GlobalBlockingHandler

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

Change #1116542 restored by Agent Isai:

[mediawiki/extensions/CheckUser@REL1_43] Specify wiki ID to ::getId call in GlobalBlockingHandler

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

Change #1116542 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@REL1_43] Cherry picked a commit which never got backported to REL1_43 and which causes an issue with CheckUser and GlobalBlocking.

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