Page MenuHomePhabricator

MobileFrontend doesn't work with Vector
Closed, ResolvedPublic

Description

According to https://www.mediawiki.org/wiki/Extension:MobileFrontend#Setup_a_skin one could set

$wgMFDefaultSkinClass = 'SkinVector';

to have MobileFrontend use Vector.

However, setting that configuration (mediawiki 1:1.35.0~rc.3-1) with multiple MobileFrontent versions, fail with:

PHP Fatal error:  Uncaught Error: Cannot use object of type RequestContext as array in /usr/share/mediawiki/includes/skins/Skin.php:157
tack trace:
#0 /var/lib/mediawiki/extensions/MobileFrontend/includes/MobileFrontendHooks.php(60): Skin->__construct(Object(RequestContext))
#1 /var/lib/mediawiki/extensions/MobileFrontend/includes/MobileFrontendHooks.php(127): MobileFrontendHooks::getDefaultMobileSkin(Object(RequestContext), Object(GlobalVarConfig))
#2 /usr/share/mediawiki/includes/HookContainer/HookContainer.php(320): MobileFrontendHooks::onRequestContextCreateSkin(Object(RequestContext), NULL)
#3 /usr/share/mediawiki/includes/HookContainer/HookContainer.php(131): MediaWiki\\HookContainer\\HookContainer->callLegacyHook('RequestContextC...', Array, Array, Array)
#4 /usr/share/mediawiki/includes/HookContainer/HookRunner.php(3221): MediaWiki\\HookContainer\\HookContainer->run('RequestContextC...', Array)
#5 /usr/share/mediawiki/includes/context/RequestContext.php(402): MediaWiki\\HookContainer\\HookRunner->onRequestContextCreateSkin( in /usr/share/mediawiki/includes/skins/Skin.php on line 157

Event Timeline

Reedy renamed this task from MobileFrontent doesn't work with Vector to MobileFrontend doesn't work with Vector.Sep 8 2020, 12:31 AM
Reedy added a project: MW-1.35-release.
Reedy updated the task description. (Show Details)
Reedy moved this task from Blocker to Not a blocker on the MW-1.35-release board.

Change 625775 had a related patch set uploaded (by Ammarpad; owner: Ammarpad):
[mediawiki/extensions/MobileFrontend@master] Don't fatal when creating new Mobile Skin

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

Ammarpad triaged this task as Medium priority.Sep 8 2020, 8:16 AM
Jdlrobson added subscribers: Ammarpad, Jdlrobson.

I can replicate it. Looks like this got broken in the SkinMustache work. I'm not sure why Context is passed to skin as a parameter. It should be an array or a string (name).

As @Ammarpad has hinted on gerrit, we need to use SkinFactory here.

I think this is the right time to switch this config to support skin key from MFDefaultSkinClass to wgDefaultMobileSkin or wgMFDefaultSkin to mirror core. This will also be more intuitive to 3rd parties.

For compatibility even thought it's inefficient we could run a compatibility mode:

$compatSkinClass = $config->get( 'MFDefaultSkinClass' );
 $mfDefaultSkin = $config->get( 'MFDefaultSkin' );
// compatiiblity mode
if ( $compatSkinName ) {
  // log warning to sysops to change value
  $skin = new $compatSkinClass();
  // https://github.com/wikimedia/mediawiki/blob/master/includes/skins/Skin.php#L168
  $mfDefaultSkin = $skin->getSkinName();
}

SkinFactory::makeSkin(  $mfDefaultSkin  )

Thoughts?

I think wgDefaultMobileSkin would be more intuitive and mirrors the core main skin variable. I am not fan of the MF acronym (and it seems not all MobileFontend config variables are using it.)

I think wgDefaultMobileSkin would be more intuitive and mirrors the core main skin variable. I am not fan of the MF acronym (and it seems not all MobileFontend config variables are using it.)

WFM!

Change 627252 had a related patch set uploaded (by Ammarpad; owner: Ammarpad):
[mediawiki/core@master] Remove problematic fallback skinname property

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

Change 627252 merged by jenkins-bot:
[mediawiki/core@master] Remove problematic fallback skinname property

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

Change 627451 had a related patch set uploaded (by Reedy; owner: Ammarpad):
[mediawiki/core@REL1_35] Remove problematic fallback skinname property

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

Change 627785 had a related patch set uploaded (by Ammarpad; owner: Ammarpad):
[mediawiki/core@master] Require Skin name or default to $wgDefaultSkin when constructing skin

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

Change 628069 had a related patch set uploaded (by Ammarpad; owner: Ammarpad):
[mediawiki/skins/Vector@master] Add skin name before calling parent constructor

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

Change 627785 merged by jenkins-bot:
[mediawiki/core@master] Require Skin name when passing options to Skin constructor

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

Which other patches from this task actually need backporting?

Change 628822 had a related patch set uploaded (by Jdlrobson; owner: Ammarpad):
[mediawiki/extensions/MobileFrontend@REL1_35] Don't fatal when creating new Mobile Skin

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

Change 627451 abandoned by Jdlrobson:
[mediawiki/core@REL1_35] Remove problematic fallback skinname property

Reason:
Doesn't need to go into branch. Allows more time for skin developers to update to support the new enforced skin name.

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

Change 628069 merged by jenkins-bot:
[mediawiki/skins/Vector@master] Clarify documentation of SkinVector::__construct()

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

Which other patches from this task actually need backporting?

Is it just https://gerrit.wikimedia.org/r/c/628822 that needs merging into REL1_35?

Change 625775 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] Don't fatal when creating new Mobile Skin

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

Change 628822 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@REL1_35] Don't fatal when creating new Mobile Skin

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