Undefined index in language.php (part 2)
Error message examples:
AH01071: Got error 'PHP message: PHP Notice: Undefined index: en_GB in lib/language.php on line 303\n'
AH01071: Got error 'PHP message: PHP Notice: Undefined index: zh_CN in lib/language.php on line 303\n'
- and so on.
The languages array contains "
en-gb" and "
zh-cn", but not "
en_GB" or "
A possible fix is to always normalize the language code before doing anything with the languages array. For example, you could insist on all lowercase with hyphens (and not underscores). If you do that, it looks like you'd need to do that normalizing:
lib/language.phpline 267 in
lib/language.phpline 303 in
is_rtl(which is triggering the notice)
'ur_PK' key in the languages array would have to be changed to
'ur-pk' (but there are other issues there, and with some of the other languages in the array).
And that looks like it should be it. There are a couple other places where the language array is used, but they don't seem to be affected by the problem:
lib/util.phpdoesn't use the languages array key, it uses the
'lang'member of the subarray (which are mostly formatted like "
en_GB", though this isn't consistent)
lib/language.phpdoesn't use the languages array key
I could implement these changes in a merge request, but I would like to get confirmation from someone familiar with the code that this is the way to go.