Page MenuHomePhabricator

Figure out how to determine if page is visited in mobile mode from onParserFirstCallInit
Closed, InvalidPublic

Event Timeline

Physikerwelt raised the priority of this task from to Medium.
Physikerwelt updated the task description. (Show Details)
Physikerwelt added a project: Mobile.
Physikerwelt added subscribers: gerritbot, TheDJ, Pkra and 5 others.

Can you elaborate? What is exactly the issue here...?
setTarget / getTarget can be found on OutputPage and should tell you this.

Another method would be (ParserFirstCallInit doesn't provide an OutputPage object) to use MobileContext directly:

$isMobileView = class_exists( 'MobileContext' ) ? MobileContext::singleton()->shouldDisplayMobileView() : false;

something like this.

You can just use the global $wgOut, but we are trying to get away from globals like that, so it's good that you bring it up..

But again, all this is irrelevant if the parser output (content) is not varied per target, which I very much doubt is the case, since even the MF reformatter runs on the total page result and not on the parser level. Perhaps we can abuse the user vary from the math option ?

@TheDJ: What is the MF reformatter.
I did some tests https://gerrit.wikimedia.org/r/#/c/203857/3/Math.hooks.php
@Florian's solution only works if the cache is cleaned an every page visit.

@Physikerwelt: https://github.com/wikimedia/mediawiki-extensions-MobileFrontend/blob/master/includes/MobileFormatter.php (i think @TheDJ was talking about that :)).
The Math extension has a user option, right? How does it work, if the extension hooks into the parser?

See https://gerrit.wikimedia.org/r/#/c/203857/3/Math.hooks.php (line 100)
the user has an option math,
the next command
$parser->getOptions()->optionUsed( 'math' )
causes that the generated output is saved with different cache keys.
So MobileFormatter would need to fetch content with a different cache key, i.e. replace math=6 by math=5

@Physikerwelt the parser should always consistently generate the same result and be agnostic to whether it is in mobile or desktop.

If you don't want this to happen you'll need to fragment your cache (e.g. replicate what Wikimedia instances do).

Is there a subset of the language you could render in the HTML output and then enhance via JavaScript?

Physikerwelt claimed this task.

@Jdlrobson Thank you, but this is no longer required, sicnce MathJax has beeen removed.