Page MenuHomePhabricator

Page view fatal from LanguageConverter: "Call to a member function isSafeToLoad() on null"
Open, HighPublic

Description

Error

MediaWiki version: 1.35.0-wmf.1

message
Call to a member function isSafeToLoad() on null

Impact

Some users are unable to view some pages due to this fatal error from /wiki/:… urls. Also aborted some API queries.

Only affects kk.wikipedia.org so far.

Details

Request ID
XaI6WgpAEMUAAB8m76cAAAAX
Request URL
/w/api.php?action=query&prop=revisions&format=xml&rvprop=content%7Cuser%7Cuserid%7Ccomment%7Cids%7Cflags%7Ctimestamp&titles=%D0%99%D0%B5%D1%82%D1%81%D0%B4%D0%BE%D1%80%D1%84
Stack Trace
exception.trace
#0 /languages/Language.php(4264): LanguageConverter->getPreferredVariant()
#1 /languages/classes/LanguageKk.php(409): Language->getPreferredVariant()
#2 /includes/cache/MessageCache.php(586): LanguageKk->lcfirst(string)
#3 /includes/cache/MessageCache.php(523): MessageCache->isMainCacheable(string, array)
#4 /includes/cache/MessageCache.php(397): MessageCache->loadFromDB(string, NULL)
#5 /includes/cache/MessageCache.php(320): MessageCache->loadFromDBWithLock(string, array, NULL)
#6 /includes/cache/MessageCache.php(1038): MessageCache->load(string)
#7 /includes/cache/MessageCache.php(965): MessageCache->getMsgFromNamespace(string, string)
#8 /includes/cache/MessageCache.php(935): MessageCache->getMessageForLang(LanguageKk, string, boolean, array)
#9 /includes/cache/MessageCache.php(877): MessageCache->getMessageFromFallbackChain(LanguageKk, string, boolean)
#10 /includes/language/Message.php(1297): MessageCache->get(string, boolean, LanguageKk)
#11 /includes/language/Message.php(852): Message->fetchMessage()
#12 /includes/language/Message.php(956): Message->toString(string)
#13 /includes/user/User.php(982): Message->plain()
#14 /extensions/CentralAuth/includes/session/CentralAuthSessionProvider.php(165): User::isUsableName(string)
#15 /includes/session/SessionManager.php(465): CentralAuthSessionProvider->provideSessionInfo(WebRequest)
#16 /includes/session/SessionManager.php(190): MediaWiki\Session\SessionManager->getSessionInfoForRequest(WebRequest)
#17 /includes/WebRequest.php(809): MediaWiki\Session\SessionManager->getSessionForRequest(WebRequest)
#18 /includes/session/SessionManager.php(129): WebRequest->getSession()
#19 /includes/Setup.php(803): MediaWiki\Session\SessionManager::getGlobalSession()
#20 /includes/WebStart.php(81): require_once(string)
#21 /api.php(36): require(string)
#22 /srv/mediawiki/w/api.php(3): require(string)
#23 {main}

Event Timeline

Krinkle created this task.Oct 13 2019, 1:20 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 13 2019, 1:20 AM

The code in question:

LanguageConverter.php
	public function getPreferredVariant() {
		global $wgUser;
		// …
		if ( $wgUser->isSafeToLoad() && $wgUser->isLoggedIn() && /* … */ ) {

... has not changed in four years. And it seems fair to expect wgUser to at least exist in general code like this. Likely has its cause elsewhere (see stack trace above).

Krinkle updated the task description. (Show Details)Oct 13 2019, 1:23 AM

Another problem with $wgUser not init was https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/533190/1/includes/cache/MessageCache.php
That was the case when exception needs messages

User::isUsableName is calling wfMessage for $wgReservedUsernames - so session needs messages and that maybe early in setup than the set of wgUser

LanguageKk::lcfirst is calling getPreferredVariant

Anomie added a subscriber: Anomie.

@Krinkle: I've noticed that this format you're using for these bugs leaves out the location where the actual error occurred (exception.file), in this case /srv/mediawiki/php-1.35.0-wmf.1/languages/LanguageConverter.php:171.

This doesn't seem to be a new error, I see log entries as far back as 2019-07-20T23:21:28 (XTOh@ApAIDgAAFqXt0IAAABS). All for kkwiki only. Probably they go back even earlier but the logs have expired.

It looks like this will only affect wikis with content language set to 'kk', as that's the only language that considers the variant in lcfirst(). It strikes me that that itself is probably a bug, case changing for the content language probably shouldn't depend on the variant being used for a particular request.

@Krinkle: I've noticed that this format you're using for these bugs leaves out the location where the actual error occurred (exception.file), in this case /srv/mediawiki/php-1.35.0-wmf.1/languages/LanguageConverter.php:171.

Also the wiki that the exception occurred on.

Krinkle added a comment.EditedOct 19 2019, 9:12 PM

@Krinkle: I've noticed that this format you're using for these bugs leaves out the location where the actual error occurred (exception.file), in this case /srv/mediawiki/php-1.35.0-wmf.1/languages/LanguageConverter.php:171.

Yeah, this is a well-intended feature from the recently-introduced Phatality plugin for Logstash. I used to copy these manually and also prefer they remain unmodified or normalised indeed. I've already mentioned this to Mukunda last month at T233349#5520650 who has since fixed it. I'm waiting for it to be deployed.

For the originating file missing, see T237682: Phatality: Keep error message and trace closer together

Krinkle renamed this task from Call to a member function isSafeToLoad() on null to Page view fatal from LanguageConverter: "Call to a member function isSafeToLoad() on null".Nov 7 2019, 7:59 PM
Krinkle added a project: MediaWiki-Parser.
daniel triaged this task as High priority.Mon, Nov 11, 8:06 PM