Page MenuHomePhabricator

Outdated LocalisationCache can cause LessVarModule to fail compilation
Closed, ResolvedPublic

Description

As described here: https://www.mediawiki.org/wiki/Topic:Vwlv0na710tu3srd I faced an issue where the translation for tap to open image text on lazy loading images was not translated in Dutch. For some reason this caused an Less compiler issue as the translation was not falling back to English. I haven't seen this behavior before and also couldn't reproduce it on another test machine, so it might be that in some cases the fallback is not working properly. At least it would help if the translation for the string mobile-frontend-tap-to-display-image can be added for various other languages. Now I just manually added it to the list, but by a new version the issue will then reappear.

Event Timeline

Jdlrobson subscribed.

Thanks for the report. Sounds like we may have a bug in ResourceLoaderLessVarFileModule, I will look into it. High as this could lead to ResourceLoader modules breaking on under translated languages.

Fallbacks do work, are tested for, and used regularly in production.

The reason adding the Dutch translation worked was mostly because modifying the file ended up either spending some time for caches to rollover post-upgrade, or it the change was detected by LocalisationCache component which then purges downstream caches, including those from ResourceLoader.

It'd help to know if you can reproduce the error by removing the Dutch translation again from the file and e.g. adding something else to the file instead (just any random "key":"value" will do). If you still encounter the Less error after the translation is removed, then I'd suspect LocalisationCache or Message.php. ResourceLoader just calls wfMessage() here to produce its string, nothing special.

Separate from this, it does remain suspicious why the error happened. Even if the cache was outdated, or if update.php was forgotten to be run after an ugprade, there should still have been a fallback to null for LESS to use so that it can at least serve a more informative error and move on instead of a hard crash. I can try to reproduce that and if consistent, we should investigate how this line and these lines can still lead to LESS complaining about an undefined variable.

@Krinkle I tried to reproduce it again by removing the string and adding a random key value pair. After removing the translation I ran update.php again, cleared memcache and browser cache and it keeps working. So really no clue why it was not working initially. Also ran the update script several times before when the issue was occuring as I updated other plugins as well.

Krinkle renamed this task from MobileFrontend missing translations causing Less compiler issues to Outdated LocalisationCache can cause LessVarModule to fail compilation.Nov 17 2020, 8:38 PM
Krinkle moved this task from Inbox to Confirmed Problem on the MediaWiki-ResourceLoader board.

Change 643604 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] resourceloader: Fail gracefully if a LESS message is not found

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

Change 643604 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Fail gracefully if a LESS message is not found

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