Page MenuHomePhabricator

mobilefrontend Uncaught Error: Call to a member function getDBkey() on null
Closed, InvalidPublic

Description

Using MobileFrontend-REL1_28-a0c8024.tar.gz with MW 1.28 release.

Error message:
[04-Feb-2017 04:27:05 Asia/Shanghai] PHP Fatal error: Uncaught Error: Call to a member function getDBkey() on null in /extensions/MobileFrontend/includes/MobileFrontend.hooks.php:51
Stack trace:
#0 /extensions/MobileFrontend/includes/MobileFrontend.hooks.php(120): MobileFrontendHooks::getDefaultMobileSkin(Object(RequestContext), Object(MobileContext))
#1 /includes/Hooks.php(195): MobileFrontendHooks::onRequestContextCreateSkin(Object(RequestContext), NULL)
#2 /includes/context/RequestContext.php(406): Hooks::run('RequestContextC...', Array)
#3 /includes/context/ContextSource.php(153): RequestContext->getSkin()
#4 /includes/OutputPage.php(2305): ContextSource->getSkin()
#5 /includes/exception/MWExceptionRenderer.php(178): OutputPage->output()
#6 /includes/exception/MWExceptionRenderer.php(50): MWExceptionRenderer::reportHTML(Object(BadMethodCallException))
#7 /includes/exception/MWExceptionHandler.php(71): MWExceptionRenderer::output(Object(BadMeth in /extensions/MobileFrontend/includes/MobileFrontend.hooks.php on line 51

Event Timeline

Jdlrobson subscribed.

If a call to RequestContext::getTitle is returning null that sounds like an issue somewhere in MediaWiki. Not MobileFrontend.
I'm not seeing an issues in Wikimedia's productions sites - so I suspect there is some kind of incompatibility issue here.

This should only happen if setTitle has not been called.
Could you give me more details on the page that is trying to be viewed. What namespace is it in?

I can't visit the link Jdlrobson provided, It require authentication.

So far I find that when visiting
"m.moegirl.org/index.php?title=Test&action=edit&redlink=1",
it will produce a 404 request and then redirect to
"m.moegirl.org/index.php?title=test&redlink=1#/editor/0"

Not sure why desktop skin style editing link were used under mobile skin. But most of these type of error originate from search engine.

Hi @Zoglun I'm not seeing the fatal you report in the description with either of these URLs - is this another problem?

The behaviour you describe also looks correct to me. "m.moegirl.org/index.php?title=Test&action=edit&redlink=1" will redirect to "m.moegirl.org/index.php?title=test&redlink=1#/editor/0" as there is no non-JavaScript editor provided by MobileFrontend.

If you visit a page which has red links and inspect the href attribute of those links they will link to a url including action=edit&redlink=1

With regards to the fatal are you able to tell me on what URL it occurs?

Unfortunately I can't provide you more info now, because the PHP error log does not contain URL, I can't match the request from log in nginx with php.

these settings will not show anything in mobile view, so I can't confirm which url causing problem.
$wgShowExceptionDetails = true;
$wgShowDebug = true;
$wgDebugToolbar = true;

Are you able to patch the MediaWiki instance so it includes this information in the error log? It's going to be really hard to replicate this without this information :(

Thank you @Zoglun! hope we can get to the bottom of this!

Hi @Jdlrobson, So I got sentry.io installed on machine and it shows me error url.

It logged many different url with this error, and I tried about ten like:
https://m.moegirl.org/%E6%81%90%E6%80%96%E8%B0%B7%E7%90%86%E8%AE%BA
https://m.moegirl.org/index.php?title=%E7%9E%B3(%E5%8D%97%E5%AE%B6%E4%B8%89%E5%A7%90%E5%A6%B9)&redlink=1#/editor/0

The only error I could found in Chrom console is "Use of "Map-values" is deprecated. mw.Map#values is deprecated. Use mw.Map#get() instead." I'm not sure weather this is related to getDBkey() on null bug.

We have corrected all Map-values problem but still receive this error in php error log.

What eventually work for us, is to switch SVG process function from PHP7's GD to imagemagick. SVG conversion by resourceloader failed with GD and seems resulting the getDBkey() on null error. Once we got the SVG conversion work with resourceloader, there are no more getDBkey() error reported.

Thanks for investigating this @Zoglun !
FYI @matmarex in case this relates to the work with ResourceLoaderImageModule...
Should we raise a bug for GD compatibility?

The getDBkey() on null is reproduce-able if purposely messed up the SVG rasterized process (No matter using PHP's GD or imagemagick) (e.g. delete the convert file of imagemagick)

The annoying point that ResourceLoaderImageModule will not generate any error long, expect leaving a ResourceLoaderImageXXXXXX file under /tmp folder. This made debug hard.

@Zoglun would you mind capturing that a task filed under MediaWiki-ResourceLoader ? Looks like something that should at least error better to avoid other people hitting this issue. Sorry this caused you inconvenience :(

I don't see how the error message posted here could be related to ResourceLoader? Am I missing something?