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

Lens0021 created this task.Aug 10 2020, 1:49 PM
Restricted Application added a project: Performance-Team. · View Herald TranscriptAug 10 2020, 1:49 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

May I ask you for some advice, @matmarex?

Gilles moved this task from Inbox to Radar on the Performance-Team board.Aug 10 2020, 7:53 PM
Gilles edited projects, added Performance-Team (Radar); removed Performance-Team.
matmarex claimed this task.Aug 10 2020, 8:45 PM

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

matmarex moved this task from To Triage to Triaged on the VisualEditor board.

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 to Doing 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 closed this task as Resolved.Aug 18 2020, 1:30 AM
Krinkle awarded a token.
Restricted Application added a project: User-Ryasmeen. · View Herald TranscriptAug 18 2020, 1:30 AM