Page MenuHomePhabricator

Custom OOUI Theme breaks ResourceLoader when used with VisualEditor
Closed, ResolvedPublic

Description

I created a custom OOUI theme by the way that explained in https://www.mediawiki.org/wiki/OOUI/Themes#Custom_themes and #Using themes in MediaWiki and it works in MW 1.34 with VE.
But in 1.35.0-rc.0 and in 1.35.0-rc.1, more strictly say, after b2ce2db332 (gerrit link), all JavaScript breaks in all skins I installed in my local wiki.

Browser console log:

Main_Page:11 GET http://localhost:8080/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector net::ERR_ABORTED 500 (Internal Server Error)

Accessing http://localhost:8080/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector will result below outputs:

[58ee199e0b429316fb07e3a5] /load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector TypeError from line 112 of /var/www/html/includes/resourceloader/ResourceLoaderOOUIImageModule.php: Return value of ResourceLoaderOOUIImageModule::loadOOUIDefinition() must be of the type array, boolean returned

Backtrace:

#0 /var/www/html/includes/resourceloader/ResourceLoaderOOUIImageModule.php(43): ResourceLoaderOOUIImageModule->loadOOUIDefinition(string, string)
#1 /var/www/html/includes/resourceloader/ResourceLoaderImageModule.php(420): ResourceLoaderOOUIImageModule->loadFromDefinition()
#2 /var/www/html/includes/resourceloader/ResourceLoaderModule.php(823): ResourceLoaderImageModule->getDefinitionSummary(ResourceLoaderContext)
#3 /var/www/html/includes/resourceloader/ResourceLoaderStartUpModule.php(209): ResourceLoaderModule->getVersionHash(ResourceLoaderContext)
#4 /var/www/html/includes/resourceloader/ResourceLoaderStartUpModule.php(405): ResourceLoaderStartUpModule->getModuleRegistrations(ResourceLoaderContext)
#5 /var/www/html/includes/resourceloader/ResourceLoaderModule.php(717): ResourceLoaderStartUpModule->getScript(ResourceLoaderContext)
#6 /var/www/html/includes/resourceloader/ResourceLoaderModule.php(685): ResourceLoaderModule->buildContent(ResourceLoaderContext)
#7 /var/www/html/includes/resourceloader/ResourceLoaderModule.php(820): ResourceLoaderModule->getModuleContent(ResourceLoaderContext)
#8 /var/www/html/includes/resourceloader/ResourceLoader.php(775): ResourceLoaderModule->getVersionHash(ResourceLoaderContext)
#9 [internal function]: ResourceLoader->{closure}(string)
#10 /var/www/html/includes/resourceloader/ResourceLoader.php(787): array_map(Closure, array)
#11 /var/www/html/includes/resourceloader/ResourceLoader.php(874): ResourceLoader->getCombinedVersion(ResourceLoaderContext, array)
#12 /var/www/html/load.php(51): ResourceLoader->respond(ResourceLoaderContext)
#13 /var/www/html/load.php(38): wfLoadMain()
#14 {main}

After investigating, I found ResourceLoader errored when trying to load extensions/VisualEditor/modules/ve-mw/ui/styles/<My_Custom_OOUI_Theme_Name>/ve.ui.Icons.json that does not exist of course.
Removing VE or checking out before "Add some typehints" commit or removing "OOUIThemePaths" and "SkinOOUIThemes" in skin.json makes the error to disappear.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I think the typehint is too strict, the loadOOUIDefinition() method can return false. Its documentation didn't mention that though and the mistake was propagated to the typehint.

Change 619363 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/core@master] ResourceLoaderOOUIImageModule: loadOOUIDefinition() may return false

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

Change 619384 had a related patch set uploaded (by Krinkle; owner: Bartosz Dziewoński):
[mediawiki/core@REL1_35] ResourceLoaderOOUIImageModule: loadOOUIDefinition() may return false

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

Krinkle triaged this task as High priority.Aug 12 2020, 2:29 AM
Krinkle edited projects, added Performance-Team; removed Performance-Team (Radar).
Krinkle moved this task from Inbox to Confirmed Problem on the MediaWiki-ResourceLoader board.
Krinkle moved this task from Inbox, needs triage to Doing (old) on the Performance-Team board.

Change 619384 merged by jenkins-bot:
[mediawiki/core@REL1_35] ResourceLoaderOOUIImageModule: loadOOUIDefinition() may return false

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

Change 619363 merged by jenkins-bot:
[mediawiki/core@master] ResourceLoaderOOUIImageModule: loadOOUIDefinition() may return false

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

Resolved in my local wiki, thank you!

Krinkle awarded a token.