User::loadFromSession called before the end of Setup.php
#0 /srv/mediawiki/php-1.35.0-wmf.8/includes/user/User.php(2264): User->load() #1 /srv/mediawiki/php-1.35.0-wmf.8/includes/user/User.php(3569): User->getId() #2 /srv/mediawiki/php-1.35.0-wmf.8/includes/user/User.php(3585): User->isRegistered() #3 /srv/mediawiki/php-1.35.0-wmf.8/extensions/UniversalLanguageSelector/includes/UniversalLanguageSelectorHooks.php(247): User->isAnon() #4 /srv/mediawiki/php-1.35.0-wmf.8/includes/Hooks.php(174): UniversalLanguageSelectorHooks::getLanguage(User, string, RequestContext) #5 /srv/mediawiki/php-1.35.0-wmf.8/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL) #6 /srv/mediawiki/php-1.35.0-wmf.8/includes/context/RequestContext.php(361): Hooks::run(string, array) #7 /srv/mediawiki/php-1.35.0-wmf.8/includes/StubUserLang.php(52): RequestContext->getLanguage() #8 /srv/mediawiki/php-1.35.0-wmf.8/includes/StubObject.php(168): StubUserLang->_newObject() #9 /srv/mediawiki/php-1.35.0-wmf.8/includes/StubObject.php(95): StubObject->_unstub(string, integer) #10 /srv/mediawiki/php-1.35.0-wmf.8/includes/content/ContentHandler.php(697): StubObject::unstub(StubUserLang) #11 /srv/mediawiki/php-1.35.0-wmf.8/includes/Title.php(4603): ContentHandler->getPageLanguage(Title) #12 /srv/mediawiki/php-1.35.0-wmf.8/includes/Title.php(3550): Title->getPageLanguage() #13 /srv/mediawiki/php-1.35.0-wmf.8/includes/Title.php(3576): Title->getCdnUrls() #14 /srv/mediawiki/php-1.35.0-wmf.8/includes/user/User.php(4057): Title->purgeSquid() #15 /srv/mediawiki/php-1.35.0-wmf.8/extensions/Wikibase/client/includes/Hooks/EchoNotificationsHandlers.php(124): User->saveSettings() #16 /srv/mediawiki/php-1.35.0-wmf.8/extensions/Wikibase/client/includes/Hooks/EchoNotificationsHandlers.php(114): Wikibase\Client\Hooks\EchoNotificationsHandlers->doLocalUserCreated(User, boolean) #17 /srv/mediawiki/php-1.35.0-wmf.8/includes/Hooks.php(174): Wikibase\Client\Hooks\EchoNotificationsHandlers::onLocalUserCreated(User, boolean) #18 /srv/mediawiki/php-1.35.0-wmf.8/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL) #19 /srv/mediawiki/php-1.35.0-wmf.8/includes/auth/AuthManager.php(1744): Hooks::run(string, array) #20 /srv/mediawiki/php-1.35.0-wmf.8/includes/Setup.php(894): MediaWiki\Auth\AuthManager->autoCreateUser(User, string, boolean) #21 /srv/mediawiki/php-1.35.0-wmf.8/includes/WebStart.php(81): require_once(string) #22 /srv/mediawiki/php-1.35.0-wmf.8/api.php(36): require(string) #23 /srv/mediawiki/w/api.php(3): require(string)
Impact
(To be determined.)
Notes
I don't yet know what caused this, whether it's urgent, or how to fix it.
But, below is an initial scan of the stack trace and its surrounding code that might help.
- User::saveSettings is calling Title::purgeSquid. It is undocumented why changing preferences requires purging the user page, unconditionally, synchronously.
public function saveSettings() { // … $this->getUserPage()->purgeSquid(); }
- Because MediaWiki does not have fixed slugs or urls for Titles, they have to be computed at run-time, and these are indeed dynamic, include possible variance on user gender and page language. Page language in turn is an customisable property of the page that extensions can hook into. One of the hook parameters, in addition to the title and the "normal" page language, is the user language. I don't know what the use case for this is or was.
- While this "interesting" hook wasn't meaningfully involved right now, the preparation code for it does run. That preparation code involves "un-stubbing" the user language object, which in turn involves another hook (UserGetLanguageObject) at RequestContext::getLanguage, which is meaningfully involved. The UniversalLanguageSelector uses it. One of the things the ULS hook varies its behaviour by is whether the user is logged-in. Determining that requires loading the User object itself first, which brings us back to where we started and violates the "User object not safe for use during Setup.php execution".
- The "just in case" mentioned in this code is in fact this case.
public function getPageLanguage( Title $title, Content $content = null ) { global $wgLang; $pageLang = MediaWikiServices::getInstance()->getContentLanguage(); // … // Simplify hook handlers by only passing objects of one type, in case nothing // else has unstubbed the StubUserLang object by now. StubObject::unstub( $wgLang ); Hooks::run( 'PageContentLanguage', [ $title, &$pageLang, $wgLang ] ); // … }