Page MenuHomePhabricator

PHP Exception: Call to a member function isMainPage() on a non-object (null)
Closed, ResolvedPublicPRODUCTION ERROR


From logstash, happened just 3 times in the last 7 days but it seems important to check:

[{exception_id}] {exception_url} BadMethodCallException from line 200 of /srv/mediawiki/php-1.31.0-wmf.6/skins/MinervaNeue/includes/skins/SkinMinerva.php: Call to a member function isMainPage() on a non-object (null)

SkinMinerva extends ContextSource and has a method getTitle which can return return Title|null.
It can be null if RequestContext::setTitle has not been called.
That said inside a skin it should be reasonable to assume you have a title to render.....


Developer notes

This appears to happen inside a series of hooks - TemplateData prepareContentForEdit
and finally CommonsMetadata\HookHandler::onContentAlterParserOutput(WikitextContent, Title, ParserOutput)

and the associated URL appears to be on /rpc/RunJobs.php

CommonsMetadata should provide a Title object

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 6 2017, 4:39 PM
Jhernandez updated the task description. (Show Details)Nov 6 2017, 4:40 PM
Jdlrobson updated the task description. (Show Details)Nov 6 2017, 8:50 PM
Restricted Application added a project: Multimedia. · View Herald TranscriptNov 6 2017, 8:55 PM
Tgr added a subscriber: Tgr.

I don't see what CommonsMetadata has to do with that. You are taking the title from the context; the context is not provided by extensions, it's set by MediaWiki on initialization. It's probably always going to be null in the job queue (and API and other similar non-web requests). Just do an isset before trying to use it.

(FWIW what's happening is: user with Minerva set as default skin uses stashed uploading -> the task of publishing the stashed upload goes into the job queue -> job queue calls recordUpload which creates the file description page -> TemplateData and CommonsMetadata trigger a parse to do validity checks -> Minerva tries to alter section edit links but takes the title from the context which doesn't exist. CommonsMetadata/TemplateData don't really have anything to do with it; they trigger the parsing earlier than normal, but even if they didn't, the parse would still have to happen - a new page is being created - and Minerva would still break.)

Change 389790 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/skins/MinervaNeue@master] Do not try to add edit links to the HTML in contexts without a Title

Change 389790 merged by jenkins-bot:
[mediawiki/skins/MinervaNeue@master] Do not try to add edit links to the HTML in contexts without a Title

Did that merged patch fix this and should this task be resolved? Or more work needed?

Jdlrobson closed this task as Resolved.Nov 20 2017, 10:22 PM
Jdlrobson claimed this task.
Jdlrobson added a subscriber: Jdlrobson.

No errors in last 2 weeks so looks fixed:

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:09 PM