Page MenuHomePhabricator

Wikimedia\Assert\PreconditionException: Expected MediaWiki\Block\AbstractBlock to belong to the local wiki, but it belongs to 'commonswiki'
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
message
[046daf12-3ac6-412d-80dd-60b42e84947f] /w/index.php?title=Special:Investigate/Account_information&token=....   Wikimedia\Assert\PreconditionException: Expected MediaWiki\Block\AbstractBlock to belong to the local wiki, but it belongs to 'commonswiki'
trace
from /srv/mediawiki/php-1.42.0-wmf.9/includes/dao/WikiAwareEntityTrait.php(59)
#0 /srv/mediawiki/php-1.42.0-wmf.9/includes/block/AbstractBlock.php(415): MediaWiki\Block\AbstractBlock->assertWiki(boolean)
#1 /srv/mediawiki/php-1.42.0-wmf.9/includes/block/AbstractBlock.php(112): MediaWiki\Block\AbstractBlock->setTarget(string)
#2 /srv/mediawiki/php-1.42.0-wmf.9/includes/block/DatabaseBlock.php(88): MediaWiki\Block\AbstractBlock->__construct(array)
#3 /srv/mediawiki/php-1.42.0-wmf.9/includes/block/DatabaseBlockStore.php(710): MediaWiki\Block\DatabaseBlock->__construct(array)
#4 /srv/mediawiki/php-1.42.0-wmf.9/includes/block/DatabaseBlockStore.php(906): MediaWiki\Block\DatabaseBlockStore->newFromRow(Wikimedia\Rdbms\DBConnRef, stdClass)
#5 /srv/mediawiki/php-1.42.0-wmf.9/extensions/CheckUser/src/Investigate/Services/PreliminaryCheckService.php(186): MediaWiki\Block\DatabaseBlockStore->newListFromConds(array)
#6 /srv/mediawiki/php-1.42.0-wmf.9/extensions/CheckUser/src/Investigate/Services/PreliminaryCheckService.php(170): MediaWiki\CheckUser\Investigate\Services\PreliminaryCheckService->isUserBlocked(integer, string)
#7 /srv/mediawiki/php-1.42.0-wmf.9/extensions/CheckUser/src/Investigate/Services/PreliminaryCheckService.php(122): MediaWiki\CheckUser\Investigate\Services\PreliminaryCheckService->getAdditionalLocalData(stdClass, string)
#8 /srv/mediawiki/php-1.42.0-wmf.9/extensions/CheckUser/src/Investigate/Pagers/PreliminaryCheckPager.php(252): MediaWiki\CheckUser\Investigate\Services\PreliminaryCheckService->preprocessResults(Wikimedia\Rdbms\MysqliResultWrapper)
#9 /srv/mediawiki/php-1.42.0-wmf.9/includes/pager/IndexPager.php(297): MediaWiki\CheckUser\Investigate\Pagers\PreliminaryCheckPager->preprocessResults(Wikimedia\Rdbms\MysqliResultWrapper)
#10 /srv/mediawiki/php-1.42.0-wmf.9/includes/pager/IndexPager.php(739): MediaWiki\Pager\IndexPager->doQuery()
#11 /srv/mediawiki/php-1.42.0-wmf.9/extensions/CheckUser/src/Investigate/SpecialInvestigate.php(317): MediaWiki\Pager\IndexPager->getNumRows()
#12 /srv/mediawiki/php-1.42.0-wmf.9/extensions/CheckUser/src/Investigate/SpecialInvestigate.php(180): MediaWiki\CheckUser\Investigate\SpecialInvestigate->addTabContent(string)
#13 /srv/mediawiki/php-1.42.0-wmf.9/includes/specialpage/SpecialPage.php(727): MediaWiki\CheckUser\Investigate\SpecialInvestigate->execute(string)
#14 /srv/mediawiki/php-1.42.0-wmf.9/includes/specialpage/SpecialPageFactory.php(1652): MediaWiki\SpecialPage\SpecialPage->run(string)
#15 /srv/mediawiki/php-1.42.0-wmf.9/includes/MediaWiki.php(359): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
#16 /srv/mediawiki/php-1.42.0-wmf.9/includes/MediaWiki.php(962): MediaWiki->performRequest()
#17 /srv/mediawiki/php-1.42.0-wmf.9/includes/MediaWiki.php(615): MediaWiki->main()
#18 /srv/mediawiki/php-1.42.0-wmf.9/index.php(50): MediaWiki->run()
#19 /srv/mediawiki/php-1.42.0-wmf.9/index.php(46): wfIndexMain()
#20 /srv/mediawiki/w/index.php(3): require(string)
#21 {main}
Impact

Unable to view the Account information tab using Special:Investigate.

Notes

Found on enwiki when checking the users 900R, Plutoisactive, and Randiajifo.

Event Timeline

Dreamy_Jazz renamed this task from [{reqId}] {exception_url} Wikimedia\Assert\PreconditionException: Expected MediaWiki\Block\AbstractBlock to belong to the local wiki, but it belongs to 'commonswiki' to Wikimedia\Assert\PreconditionException: Expected MediaWiki\Block\AbstractBlock to belong to the local wiki, but it belongs to 'commonswiki'.Dec 18 2023, 10:49 AM

Are you using enwiki to look at that special page? In the context of cross-wiki blocks it is relevant from which wiki the request is done to know what "local" refers to.

The calling code to get the block was changed in c8cbeec824a3b0cb03d1896d0841dc631b4e34b1, before that change the address of the block was not loaded and therefore a mismatch between the wikiid of the database and the UserIdentity of the address was not asserted and not failing.

After the change AbstractBlock::setTarget is trying to set the target from a string address (getting it from the database $row->ipb_address), the BlockUtils service is converting this to a local UserIdentity, but BlockUtils is not aware of the wikiid of the DatabaseBlockStore service used to load the block, as the BlockUtils service is not aware of wiki id at all, also using the local UserIdentityLookup service creating local UserIdentity and that fails.
Seems that T286490 missed the part where a block is loaded from database and was only build to show self created block objects.

Are you using enwiki to look at that special page? In the context of cross-wiki blocks it is relevant from which wiki the request is done to know what "local" refers to.

The logstash entries show en.wikipedia.org. I was not the one to run the check, but that seems likely to be the "local wiki".

Change 987460 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/core@master] Make BlockUtils a wiki-aware service

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

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

[mediawiki/extensions/CentralAuth@master] Revert "Support new block schema"

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

I reproduced the bug locally and confirmed that reverting the CentralAuth change fixes it.

I reproduced the bug locally and confirmed that reverting the CentralAuth change fixes it.

Sorry that comment should have been on T354298.

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

[mediawiki/extensions/CheckUser@master] Revert "Get blocks from DatabaseBlockStore instead of doing our own query"

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

I reproduced the bug locally and confirmed that reverting the CentralAuth change fixes it.

Sorry that comment should have been on T354298.

But I have now reproduced this CheckUser bug also.

Change 987460 merged by jenkins-bot:

[mediawiki/core@master] Make BlockUtils a wiki-aware service

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

Change 987472 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] Revert "Get blocks from DatabaseBlockStore instead of doing our own query"

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

Change 987483 had a related patch set uploaded (by Zabe; author: Tim Starling):

[mediawiki/extensions/CheckUser@wmf/1.42.0-wmf.12] Revert "Get blocks from DatabaseBlockStore instead of doing our own query"

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

Change 987483 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@wmf/1.42.0-wmf.12] Revert "Get blocks from DatabaseBlockStore instead of doing our own query"

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

Mentioned in SAL (#wikimedia-operations) [2024-01-04T12:56:52Z] <zabe@deploy2002> Started scap: Backport for [[gerrit:987483|Revert "Get blocks from DatabaseBlockStore instead of doing our own query" (T353620)]], [[gerrit:987482|Revert "Support new block schema" (T354298)]]

Mentioned in SAL (#wikimedia-operations) [2024-01-04T13:00:29Z] <zabe@deploy2002> zabe: Backport for [[gerrit:987483|Revert "Get blocks from DatabaseBlockStore instead of doing our own query" (T353620)]], [[gerrit:987482|Revert "Support new block schema" (T354298)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2024-01-04T13:06:58Z] <zabe@deploy2002> Finished scap: Backport for [[gerrit:987483|Revert "Get blocks from DatabaseBlockStore instead of doing our own query" (T353620)]], [[gerrit:987482|Revert "Support new block schema" (T354298)]] (duration: 10m 06s)

tstarling assigned this task to Zabe.

Should be fixed. No further log entries, although the rate was very low to start with.