Page MenuHomePhabricator

TranslatablePage: Error: Call to a member function getSourceLanguage() on null
Closed, ResolvedPublicPRODUCTION ERROR

Description

Steps to replicate the issue (include links if applicable):

What happens?:
2022-11-27 09:12:13: Fatal exception of type "Error"

What should have happened instead?:
Show the translated subpage of /Activities

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline

Minorax updated the task description. (Show Details)

I'd like to add that editing from Special:Translate is still possible.

Reedy subscribed.

What error are you getting? Can you post the whole error message, include the code?

Visiting all the pages on https://meta.wikimedia.org/wiki/Special:PrefixIndex/Wiki_Loves_Butterfly/Activities work fine for me logged in...

Weird that I can't replicate the error now, had problems with it for a full hour just now. Asked someone else to try it just now and had the same issue.

Error
normalized_message
[{reqId}] {exception_url}   Error: Call to a member function getSourceLanguage() on null
exception.trace
from /srv/mediawiki/php-1.40.0-wmf.10/extensions/Translate/src/PageTranslation/TranslatablePage.php(454)
#0 /srv/mediawiki/php-1.40.0-wmf.10/extensions/Translate/src/PageTranslation/Hooks.php(226): MediaWiki\Extension\Translate\PageTranslation\TranslatablePage->getRevisionRecordWithFallback()
#1 /srv/mediawiki/php-1.40.0-wmf.10/includes/HookContainer/HookContainer.php(338): MediaWiki\Extension\Translate\PageTranslation\Hooks::fetchTranslatableTemplateAndTitle(Title, Title, boolean, NULL)
#2 /srv/mediawiki/php-1.40.0-wmf.10/includes/HookContainer/HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook(string, array, array, array)
#3 /srv/mediawiki/php-1.40.0-wmf.10/includes/HookContainer/HookRunner.php(985): MediaWiki\HookContainer\HookContainer->run(string, array)
#4 /srv/mediawiki/php-1.40.0-wmf.10/includes/parser/Parser.php(3654): MediaWiki\HookContainer\HookRunner->onBeforeParserFetchTemplateRevisionRecord(Title, Title, boolean, NULL)
#5 /srv/mediawiki/php-1.40.0-wmf.10/includes/parser/Parser.php(3595): Parser::statelessFetchTemplate(Title, Parser)
#6 /srv/mediawiki/php-1.40.0-wmf.10/includes/parser/Parser.php(3488): Parser->fetchTemplateAndTitle(Title)
#7 /srv/mediawiki/php-1.40.0-wmf.10/includes/parser/Parser.php(3229): Parser->getTemplateDom(Title)
#8 /srv/mediawiki/php-1.40.0-wmf.10/includes/parser/PPFrame_Hash.php(275): Parser->braceSubstitution(array, PPFrame_Hash)
#9 /srv/mediawiki/php-1.40.0-wmf.10/includes/parser/Parser.php(2942): PPFrame_Hash->expand(PPNode_Hash_Tree, integer)
#10 /srv/mediawiki/php-1.40.0-wmf.10/includes/parser/Parser.php(1600): Parser->replaceVariables(string)
#11 /srv/mediawiki/php-1.40.0-wmf.10/includes/parser/Parser.php(714): Parser->internalParse(string)
#12 /srv/mediawiki/php-1.40.0-wmf.10/includes/content/WikitextContentHandler.php(303): Parser->parse(string, Title, ParserOptions, boolean, boolean, integer)
#13 /srv/mediawiki/php-1.40.0-wmf.10/includes/content/ContentHandler.php(1745): WikitextContentHandler->fillParserOutput(WikitextContent, MediaWiki\Content\Renderer\ContentParseParams, ParserOutput)
#14 /srv/mediawiki/php-1.40.0-wmf.10/includes/content/Renderer/ContentRenderer.php(47): ContentHandler->getParserOutput(WikitextContent, MediaWiki\Content\Renderer\ContentParseParams)
#15 /srv/mediawiki/php-1.40.0-wmf.10/includes/Revision/RenderedRevision.php(266): MediaWiki\Content\Renderer\ContentRenderer->getParserOutput(WikitextContent, Title, integer, ParserOptions, boolean)
#16 /srv/mediawiki/php-1.40.0-wmf.10/includes/Revision/RenderedRevision.php(237): MediaWiki\Revision\RenderedRevision->getSlotParserOutputUncached(WikitextContent, boolean)
#17 /srv/mediawiki/php-1.40.0-wmf.10/includes/Revision/RevisionRenderer.php(227): MediaWiki\Revision\RenderedRevision->getSlotParserOutput(string, array)
#18 /srv/mediawiki/php-1.40.0-wmf.10/includes/Revision/RevisionRenderer.php(164): MediaWiki\Revision\RevisionRenderer->combineSlotOutput(MediaWiki\Revision\RenderedRevision, array)
#19 [internal function]: MediaWiki\Revision\RevisionRenderer->MediaWiki\Revision\{closure}(MediaWiki\Revision\RenderedRevision, array)
#20 /srv/mediawiki/php-1.40.0-wmf.10/includes/Revision/RenderedRevision.php(199): call_user_func(Closure, MediaWiki\Revision\RenderedRevision, array)
#21 /srv/mediawiki/php-1.40.0-wmf.10/includes/poolcounter/PoolWorkArticleView.php(87): MediaWiki\Revision\RenderedRevision->getRevisionParserOutput()
#22 /srv/mediawiki/php-1.40.0-wmf.10/includes/poolcounter/PoolWorkArticleViewCurrent.php(92): PoolWorkArticleView->renderRevision()
#23 /srv/mediawiki/php-1.40.0-wmf.10/includes/poolcounter/PoolCounterWork.php(163): PoolWorkArticleViewCurrent->doWork()
#24 /srv/mediawiki/php-1.40.0-wmf.10/includes/page/ParserOutputAccess.php(299): PoolCounterWork->execute()
#25 /srv/mediawiki/php-1.40.0-wmf.10/includes/page/Article.php(708): MediaWiki\Page\ParserOutputAccess->getParserOutput(WikiPage, ParserOptions, MediaWiki\Revision\RevisionStoreCacheRecord, integer)
#26 /srv/mediawiki/php-1.40.0-wmf.10/includes/page/Article.php(522): Article->generateContentOutput(User, ParserOptions, integer, OutputPage, array)
#27 /srv/mediawiki/php-1.40.0-wmf.10/includes/actions/ViewAction.php(78): Article->view()
#28 /srv/mediawiki/php-1.40.0-wmf.10/includes/MediaWiki.php(540): ViewAction->show()
#29 /srv/mediawiki/php-1.40.0-wmf.10/includes/MediaWiki.php(317): MediaWiki->performAction(Article, Title)
#30 /srv/mediawiki/php-1.40.0-wmf.10/includes/MediaWiki.php(902): MediaWiki->performRequest()
#31 /srv/mediawiki/php-1.40.0-wmf.10/includes/MediaWiki.php(560): MediaWiki->main()
#32 /srv/mediawiki/php-1.40.0-wmf.10/index.php(50): MediaWiki->run()
#33 /srv/mediawiki/php-1.40.0-wmf.10/index.php(46): wfIndexMain()
#34 /srv/mediawiki/w/index.php(3): require(string)
#35 {main}
Reedy changed the subtype of this task from "Bug Report" to "Production Error".Nov 27 2022, 10:20 AM
	public function getMessageGroup(): ?WikiPageMessageGroup {
		$groupId = $this->getMessageGroupId();
		$group = MessageGroups::getGroup( $groupId );
		if ( !$group || $group instanceof WikiPageMessageGroup ) {
			return $group;
		}

		throw new RuntimeException(
			"Expected $groupId to be of type WikiPageMessageGroup; got " .
			get_class( $group )
		);
	}

^ can clearly return null, but getRevisionRecordWithFallback doesn't check/cater for null. Not sure if it's expected, but clearly happens, sometimes...

Useage seems the same since implementation in rETRA42e48e170bf9: Enable "opt-out" translation aware transclusion for templates

Reedy renamed this task from Internal error on Wiki_Loves_Butterfly/Activities to TranslatablePage: Error: Call to a member function getSourceLanguage() on null.Nov 27 2022, 10:28 AM

Change 861832 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/extensions/Translate@master] Template transclusion: Log cases where fetching RevisionRecord fails

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

Change 861832 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Template transclusion: Log cases where fetching RevisionRecord fails

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

I tried reproducing this locally and wasn't able to. Although getMessageGroup method can return null, in the codepath triggered by: PageTranslation\Hooks::fetchTranslatableTemplateAndTitle checks that the translatable page is marked.

The message group cache (getMessageGroup uses this to fetch the group) is updated immediately after marking the translatable page. Since TranslatablePage::isTranslationPage checks that the page has the marked tag, getMessageGroup should return a value.

In theory, there should be some more logging this time…

In theory, there should be some more logging this time…

The patch will be deployed this week, so no logs yet.

It is deployed now, and I see some entries in Logstash.

image.png (593×2 px, 64 KB)

Change 867111 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/extensions/Translate@master] Template transclusion: Add more logs when fetching RevisionRecord fails

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

I see some logs now: https://logstash.wikimedia.org/goto/a7aa9182b6a523ce315f553570c792f6

  1. 301 hits on 2022-12-10
  2. 24 hits on 2022-12-12

I've added some more logs to pin point the issue better.

Change 867111 abandoned by Abijeet Patro:

[mediawiki/extensions/Translate@master] Template transclusion: Add more logs when fetching RevisionRecord fails

Reason:

Not needed.

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

This error still occurs consistently.

In the last 4 weeks, this error has occurred 157 times which is less than before but still high. The only hypothesis I have is that the message group cache is not upto date.

I see similar cases appear for other occurrences of the error. It appears that the error appears for a while when the page is already transcluded in another page and then marked for translation. After the page is marked for translation, it takes a bit for the message group cache to update.

Change 899524 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/extensions/Translate@master] Use TranslatablePage source language code when fetching fallback

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

Change 899524 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Use TranslatablePage source language code when fetching fallback

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

Did not see any occurrences of this error in the last 10 days. Keeping it open for a couple of days to re-review the logs.

I see that this is still happening, but much less frequently. In the last 12 days, this has happened 10 times. I think one way to solve this would be to use READ_LATEST in order to read from the primary database but since this issue should fix itself quickly, probably not worth it.

This has occurred 11 times in the last 23 days. Marking this as done.

I see that this has happened 143 times in the last 4 weeks ... which is much higher than last time. I'll create another task to investigate this.