I think I may uncovered a bug and a fix for this. I need you all to shoot holes in this, because this has been coded like this since at least 6.5. In mainfile.php is this code. I added the numbers for reference.
Line 3 does an IF test to see if there is a language file in the module/MODULENAME folder. If NOT the IF test fails and the logic drops into Line 9. If the $module is NOT equal to admin, which is also an error as it should be "admin" if not something else (who knows?) it has to drop into line 13 which is also looking for a language folder in the module/MODULENAME (but a different language variable). But, if the language folder is non existent then it errors. Thus, you get the infamous Warning: get_lang error!
I believe the function should be written like this, at a minimum.
Code:
function get_lang($module) {
global $currentlang, $language;
if (file_exists("modules/$module/language/lang-$currentlang.php")) {
if ($module == "admin") {
include_once("admin/language/lang-$currentlang.php");
} else {
include_once("modules/$module/language/lang-$currentlang.php");
}
}
elseif (file_exists("modules/$module/language/lang-$language.php")) {
if ($module == "admin") {
include_once("admin/language/lang-$language.php");
} else {
include_once("modules/$module/language/lang-$language.php");
}
} else {
if ($module == "admin") {
include_once("admin/language/lang-$currentlang.php");
} else {
include_once("language/lang-$language.php");
}
}
}
I also am very unclear as to why/how the usage of the 2 different language variables come into play on this. But, that's neither here nor there right now. Please help prove/disprove this code. It certainly cleared up errors for several people so far. Thanks!
As I read it, the two language variables represent the currently selected language ($currentlang) and the default language for the site ($language ... from nuke_config table).
I think the code is assuming that the language in the nuke_config will always be correct and available, but you're correct that it should be more informative when it fails.
Joined: Aug 28, 2003 Posts: 6373 Location: Vsetin, Czech Republic
Posted:
Thu May 12, 2005 7:38 pm
OK, lets have a bet to see which version Fb includes this is and which subsequent version it gets dropped from.
I have $20 on 7.8 and 7.9 respectively hehehe.
Well caught Raven!
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum