Page MenuHomePhabricator

QuickTemplate: PHP Notice: Undefined index: skin
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error

MediaWiki version: 1.35.0-wmf.28

message
PHP Notice: Undefined index: skin

Impact

Unclear.

Notes

This goes back to at least 1.35.0-wmf.24 at a fairly low volume, but I wasn't able to find an open task for it.

Developer notes

This seems to be occuring in the save_collection command which can be found on Special:Book with the following configuration and clicking "save book" in Save and share your book.

It is only triggered when you rewrite (e.g. hit save on a page that already exists)

wfLoadExtension('Collection');

$wgGroupPermissions['*']['collectionsaveasuserpage'] = true;
$wgGroupPermissions['*']['collectionsaveascommunitypage'] = true;

The issue is getSkin requires a 'skin' value to be set on the SkinTemplate. This isn't happening. Likely introduced in January by @DannyS712 while working on T241616. Collection is a pain to test, so easy mistake to make.

Details

Request ID
Xqm3hgpAICkAAKGzQfEAAABP
Request URL
https://ru.wikipedia.org/wiki/%D0%A1%D0%BB%D1%83%D0%B6%D0%B5%D0%B1%D0%BD%D0%B0%D1%8F:%D0%9A%D0%BE%D0%BB%D0%BB%D0%B5%D0%BA%D1%86%D0%B8%D1%8F_%D0%BA%D0%BD%D0%B8%D0%B3
Stack Trace
exception.trace
#0 /srv/mediawiki/php-1.35.0-wmf.28/includes/skins/QuickTemplate.php(155): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.35.0-wmf.28/extensions/Collection/templates/CollectionSaveOverwriteTemplate.php(26): QuickTemplate->getSkin()
#2 /srv/mediawiki/php-1.35.0-wmf.28/includes/skins/QuickTemplate.php(166): CollectionSaveOverwriteTemplate->execute()
#3 /srv/mediawiki/php-1.35.0-wmf.28/includes/OutputPage.php(2012): QuickTemplate->getHTML()
#4 /srv/mediawiki/php-1.35.0-wmf.28/extensions/Collection/includes/Specials/SpecialCollection.php(1381): OutputPage->addTemplate(CollectionSaveOverwriteTemplate)
#5 /srv/mediawiki/php-1.35.0-wmf.28/extensions/Collection/includes/Specials/SpecialCollection.php(382): SpecialCollection->renderSaveOverwritePage(string, Title, string, NULL)
#6 /srv/mediawiki/php-1.35.0-wmf.28/extensions/Collection/includes/Specials/SpecialCollection.php(242): SpecialCollection->processSaveCollectionCommand()
#7 /srv/mediawiki/php-1.35.0-wmf.28/includes/specialpage/SpecialPage.php(576): SpecialCollection->execute(NULL)
#8 /srv/mediawiki/php-1.35.0-wmf.28/includes/specialpage/SpecialPageFactory.php(618): SpecialPage->run(NULL)
#9 /srv/mediawiki/php-1.35.0-wmf.28/includes/MediaWiki.php(299): MediaWiki\SpecialPage\SpecialPageFactory->executePath(Title, RequestContext)
#10 /srv/mediawiki/php-1.35.0-wmf.28/includes/MediaWiki.php(973): MediaWiki->performRequest()
#11 /srv/mediawiki/php-1.35.0-wmf.28/includes/MediaWiki.php(535): MediaWiki->main()
#12 /srv/mediawiki/php-1.35.0-wmf.28/index.php(47): MediaWiki->run()
#13 /srv/mediawiki/w/index.php(3): require(string)
#14 {main}

Event Timeline

Basically $this->set( 'skin', SOMEVALUE ); is never called

Krinkle added subscribers: Jdlrobson, Krinkle.

Looks like this might relate to recent Skin or Vector refactoring having moved around the QuickTemplate::set calls. If the skin is undefined in some cases, that could presumably have quite serious side-effects on the page view.

https://logstash.wikimedia.org/goto/b617270e9ff6edf6275c8e4e006e1176

The error reported here is "just" a PHP Notice, but given that this falls back to null, it does cause a fatal error as well, which is reported on the next line for the same requests. For example:

Fatal error:  Call to a member function getUser() on null

 #0 /srv/mediawiki/php-1.35.0-wmf.30/includes/skins/QuickTemplate.php(166): CollectionSaveOverwriteTemplate->execute()

I hit a similar bug while working on https://gerrit.wikimedia.org/r/593040

Basically if getSkin() is used in the method anywhere, $this->setupTemplateContext(); needs to be called.

I can take a look at this today. It might be that patch above fixes this but I'll try and get a MTC.

Change 594810 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/extensions/Collection@master] Set skin on BaseTemplates if you are using getSkin

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

oKay - fix up. Likely been broken since January,

Change 594817 had a related patch set uploaded (by Krinkle; owner: Jdlrobson):
[mediawiki/extensions/Collection@wmf/1.35.0-wmf.31] Set skin on BaseTemplates if you are using getSkin

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

Change 594810 merged by jenkins-bot:
[mediawiki/extensions/Collection@master] Set skin on BaseTemplates if you are using getSkin

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

Change 594817 merged by jenkins-bot:
[mediawiki/extensions/Collection@wmf/1.35.0-wmf.31] Set skin on BaseTemplates if you are using getSkin

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

Mentioned in SAL (#wikimedia-operations) [2020-05-07T15:36:15Z] <jforrester@deploy1001> Synchronized php-1.35.0-wmf.31/extensions/Collection/includes/Specials/SpecialCollection.php: T251460 Set skin on BaseTemplates if you are using getSkin (duration: 01m 08s)

Krinkle assigned this task to Jdlrobson.