Page MenuHomePhabricator

"Expected MediaWiki\User\User to belong to 'metawiki', but it belongs to the local wiki" accessing any beta site while logged in
Closed, ResolvedPublicBUG REPORT

Description

What is the problem?

When I go to any beta site, I see the exception:

Original exception: [Ztm-vidQfSBZFdAwuHK3fgAAAAY] /wiki/Main_Page Wikimedia\Assert\PreconditionException: Expected MediaWiki\User\User to belong to 'metawiki', but it belongs to the local wiki
Backtrace:
from /srv/mediawiki/php-master/includes/dao/WikiAwareEntityTrait.php(59)
#0 /srv/mediawiki/php-master/extensions/CentralAuth/includes/User/CentralAuthIdLookup.php(109): MediaWiki\User\User->assertWiki(string)
#1 /srv/mediawiki/php-master/extensions/GlobalUserPage/includes/GlobalUserPage.php(218): MediaWiki\Extension\CentralAuth\User\CentralAuthIdLookup->isAttached(MediaWiki\User\User, string)
#2 /srv/mediawiki/php-master/extensions/GlobalUserPage/includes/Hooks.php(77): MediaWiki\GlobalUserPage\GlobalUserPage::shouldDisplayGlobalPage(MediaWiki\Title\Title)
#3 /srv/mediawiki/php-master/includes/HookContainer/HookContainer.php(159): MediaWiki\GlobalUserPage\Hooks->onTitleIsAlwaysKnown(MediaWiki\Title\Title, null)
#4 /srv/mediawiki/php-master/includes/HookContainer/HookRunner.php(3988): MediaWiki\HookContainer\HookContainer->run(string, array)
#5 /srv/mediawiki/php-master/includes/title/Title.php(3165): MediaWiki\HookContainer\HookRunner->onTitleIsAlwaysKnown(MediaWiki\Title\Title, null)
#6 /srv/mediawiki/php-master/includes/title/Title.php(3206): MediaWiki\Title\Title->isAlwaysKnown()
#7 /srv/mediawiki/php-master/includes/skins/Skin.php(1175): MediaWiki\Title\Title->isKnown()
#8 /srv/mediawiki/php-master/includes/skins/SkinTemplate.php(127): Skin::makeUrlDetails(MediaWiki\Title\Title)
#9 /srv/mediawiki/php-master/includes/skins/SkinMustache.php(88): SkinTemplate->setupTemplateContext()
#10 /srv/mediawiki/php-master/includes/skins/SkinTemplate.php(179): SkinMustache->generateHTML()
#11 /srv/mediawiki/php-master/includes/Output/OutputPage.php(3136): SkinTemplate->outputPage()
#12 /srv/mediawiki/php-master/includes/actions/ActionEntryPoint.php(162): MediaWiki\Output\OutputPage->output(bool)
#13 /srv/mediawiki/php-master/includes/MediaWikiEntryPoint.php(200): MediaWiki\Actions\ActionEntryPoint->execute()
#14 /srv/mediawiki/php-master/index.php(58): MediaWiki\MediaWikiEntryPoint->run()
#15 /srv/mediawiki/w/index.php(3): require(string)
#16 {main}

It seems to only happen when I am logged in. It seems to happen on all pages I have tried.

Steps to reproduce problem
  1. https://en.wikipedia.beta.wmflabs.org
  2. Log in (if you are not already)

Expected behaviour: Page loads.
Observed behaviour: Above exception.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Zabe subscribed.

Should be easy to fix

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

[mediawiki/extensions/GlobalUserPage@master] Do not use full User objects for cross-wiki stuff in GlobalUserPage

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

Thanks @JJMC89

Noting here that there are enough of these on beta to make scap's logstash checker is sad about it: beta-scap-sync-world#170843

Change #1070982 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/CentralAuth@master] Revert "CentralAuthIdLookup: Improve assertions, type hints, comments"

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

Should be easy to fix

One would hope, but the patch has CI failures that I don't immediately understand. I'll revert the change that caused this for now, so that either one of us can look into them in peace. Thanks for proposing the fix though, hopefully we can merge it soon and reapply the original patch.

Change #1070982 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Revert "CentralAuthIdLookup: Improve assertions, type hints, comments"

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

matmarex claimed this task.

The beta cluster works again, so I call this resolved.

I'm going to submit a new version of the reverted patch without the $user->assertWiki( $wikiId ); addition that caused this problem, to unblock my other CentralAuth SUL3 work that depended on it; and I'll file a separate task about adding it again, and making GlobalUserPage work with that (I'm not planning to work on that right now, but I'll be happy to review if you @Zabe or anyone else wants to get it working).