Page MenuHomePhabricator

mw.uls.getBrowserLanguage is not a function
Closed, ResolvedPublicBUG REPORT

Description

Exception in module-execute in module ext.cx.uls.quick.actions: load.php:1:871

TypeError: mw.uls.getBrowserLanguage is not a function
    at getSuggestedTargetLanguage 
    at load.php
    at entrypoints/ext.cx.uls.quick.actions.js

Happens on the Welcome Survey. Reported by @Etonkovidova. Can't find it in the clienterror logs.

Event Timeline

A similar error that does show up in the logs (although only a tiny number of times) is TypeError: (intermediate value).split is not a function. That one is not related to the welcome survey though (it happens on articles).

Tgr edited projects, added ContentTranslation; removed Growth-Team.

On a closer look the getSuggestedTargetLanguage method is from the ContentTranslation extension, so this is probably not related to the welcome survey (which only uses ULS to display a language field in the form).

Nardog subscribed.
This comment was removed by Nardog.

mw.loader.getState('ext.cx.uls.quick.actions') is returning error. The module seems to have been added in bab062314d03.

On the dewiki homepage mw.uls contains only ActionsMenuItemsRegistry which is an empty object. This is different from, say, dewiktionary where mw.uls.getBrowserLanguage does exist.

After the gear icon next to "In other languages" is clicked on dewiki, mw.uls.getBrowserLanguage does exist. Seems sensible enough to me, so probably a performance enhancement. Not sure why it differs from other projects though.

On https://de.wikipedia.org/wiki/Wasser the error is triggered when "Use a compact language list, with languages relevant to you." has been disabled in user preferences, otherwise there's no error.

On https://en.wikipedia.org/wiki/Main_Page I don't see the compact list despite having it enabled. Same on dewiki.

https://en.wikipedia.beta.wmflabs.org/wiki/Main_Page also triggers the error.

The module from @ngkountas should probably check if ULS has been loaded before trying to add any links. I assume that module is responsible for the grey links at the top of the compact language list?

Change 797031 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] CX ULS quick action entrypoint: Add "ext.uls.common" as a dependency

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

Change 797031 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] CX ULS quick action entrypoint: Add "ext.uls.common" as a dependency

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

Unable to reproduce after fix. Marking as done

Thank you.

Change 797031 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] CX ULS quick action entrypoint: Add "ext.uls.common" as a dependency

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

Just out of curiosity, will adding that dependency increase the load time? I thought these translation links already existed before JS error, so I wonder why an additional dependency is needed.