Page MenuHomePhabricator

OOJS-UI failure from GlobalPreferences code on live enwiki
Closed, ResolvedPublicBUG REPORT

Description

As of now, I consistently get a JavaScript failure when visiting https://en.wikipedia.org/wiki/Special:Preferences#mw-prefsection-rendering.

Exception in module-execute in module ext.GlobalPreferences.local:
Error: Unknown widget type: id: ooui-php-76, class: mw.widgets.UsersMultiselectWidget
    at Object.OO.ui.Element.static.unsafeInfuse (load.php?lang=en&modules=ext.GlobalPreferences.local|jquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=vector&version=z53ft:152)
    at Object.OO.ui.Element.static.infuse (load.php?lang=en&modules=ext.GlobalPreferences.local|jquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=vector&version=z53ft:151)
    at Object.OO.ui.infuse (load.php?lang=en&modules=ext.GlobalPreferences.local|jquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=vector&version=z53ft:148)
    at updatePrefInput (load.php?lang=en&modules=ext.GlobalPreferences.local|jquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=vector&version=z53ft:1)
    at HTMLSpanElement.<anonymous> (load.php?lang=en&modules=ext.GlobalPreferences.local|jquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=vector&version=z53ft:2)
    at Function.each (load.php?lang=en&modules=ext.GlobalPreferences.local|jquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=vector&version=z53ft:6)
    at jQuery.fn.init.each (load.php?lang=en&modules=ext.GlobalPreferences.local|jquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=vector&version=z53ft:4)
    at load.php?lang=en&modules=ext.GlobalPreferences.local|jquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=vector&version=z53ft:1
    at load.php?lang=en&modules=ext.GlobalPreferences.local|jquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=vector&version=z53ft:2
    at runScript (load.php?lang=en&modules=startup&only=scripts&raw=1&safemode=1&skin=vector:12)

The ooui-php-76 element this exception talks about is the email-blacklist preference from core: https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/preferences/DefaultPreferencesFactory.php$792. This is marked as 'type' => 'usersmultiselect', which translates to HTMLUsersMultiselectField in PHP and mw.widgets.UsersMultiselectWidget in JavaScript.

In the MediaWiki-extensions-GlobalPreferences extension.json we find:

"ext.GlobalPreferences.global": {"dependencies": ["mediawiki.widgets.UsersMultiselectWidget"
	],

But the failure doesn't mention the ….global module. It's about the ….local module. This one doesn't list the widget as a dependency. Is this a mistake? Why is it even necessary in the first place that an extension lists dependencies for stuff that doesn't really have anything to do with the extension, but is entirely in core?

The best theory I have is that core intentionally skips loading the widget when the field is disabled, and GlobalPreferences needs to force loading it if it want's to enable the field. If this is true it would hint at a fragile design, in my opinion. A change in core will break the extension when it's not updated the same time. This is not sustainable, isn't it?

This issue continues what looks like a trend at this point:

Event Timeline

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

Change 745534 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/GlobalPreferences@master] Add missing UsersMultiselectWidget dependency

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

In fact, https://gerrit.wikimedia.org/r/c/743024 is good enough, all we need is to handle the 'htmlform.enhance' hook rather than add the dependencies.

Updated: Sorry, that patch invisibly relied on the result of other scripts in the core.

Change 745534 merged by jenkins-bot:

[mediawiki/extensions/GlobalPreferences@master] Add missing UsersMultiselectWidget dependency

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

MusikAnimal claimed this task.

Thanks for identifying this issue and fixing it! I see it is live now on wmf.13, as well as T272302 and its patches, and with that I'm no longer seeing this error. Closing as resolved.