zotonic/zotonic — Issue #243: Logon failure when set_language fails
Author: mmzeeman
Created: 2011-10-27 10:18:16+00:00
State: open
Labels: defect

set_language can fail with a function clause exception when the language it tries to set is not found in the language list..

It should probably set the language to the default language when it is out of options.

When this happens, admin can no longer log into the site.

This error was triggered because of an inconsistancy in the language availabily list.

A language was editted the iso language code was changed from "sv_se" to "sv". Later on the site tried to use "sv_se" as key. Also after restarting.

Then it is called in this way, which leads to the function clause exception.

DEBUG: mod_translation:200 {"sv_se",
[{de,[{language,<<"Deutsch">>},
{is_enabled,true}]},
{en,[{language,<<"English">>},
{is_enabled,true}]},
{es,[{language,<<"EspaÃ±ol">>},
{is_enabled,true}]},
{fr,[{is_enabled,true},
{language,<<"FranÃ§ais">>}]},
{nl,[{is_enabled,true},
{language,<<"Nederlands">>}]},
{sv,[{language,<<"Svenska">>},
{is_enabled,true}]},
{tr,[{is_enabled,true},
{language,<<"TÃ¼rkÃ§e">>}]},
{zh_cn,[{language,<<228,184,173,229,155,189>>},
{is_enabled,true}]}]}