Author |
Message |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Wed Oct 01, 2003 5:01 pm |
|
Warning: get_lang(modules/somemodule/language/lang-english.php):
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. Code:1. function get_lang($module) {
2. global $currentlang, $language;
3. if (file_exists("modules/$module/language/lang-$currentlang.php")) {
4. if ($module == admin) {
5. include_once("admin/language/lang-$currentlang.php");
6. } else {
7. include_once("modules/$module/language/lang-$currentlang.php");
8. }
9, } else {
10. if ($module == admin) {
11. include_once("admin/language/lang-$currentlang.php");
12. } else {
13. include_once("modules/$module/language/lang-$language.php");
14. }
15. }
16. }
|
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! |
|
|
|
 |
vjg
New Member


Joined: Mar 09, 2004
Posts: 1
|
Posted:
Tue Mar 09, 2004 4:46 pm |
|
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.
- Virgil |
|
|
|
 |
CoLoR
New Member


Joined: Aug 11, 2004
Posts: 2
|
Posted:
Sat Oct 16, 2004 2:49 pm |
|
perfect Raven,
It is working for me,
Thankzzz  |
|
|
|
 |
cybercase
New Member


Joined: May 12, 2005
Posts: 1
Location: Germany
|
Posted:
Thu May 12, 2005 1:27 pm |
|
I found your patch and although were now in May 2005 , I inserted the code in mainfile.php (PHP-Nuke 7.6) and it is working like a dream
Thanks  |
|
|
 |
 |
Raven

|
Posted:
Thu May 12, 2005 3:32 pm |
|
|
|
 |
Guardian2003
Site Admin

Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam
|
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! |
|
|
|
 |
Raven

|
Posted:
Thu May 12, 2005 7:45 pm |
|
Quote: | Posted: Wed Oct 01, 2003 6:01 pm | After 2 years, and the fact that I doubt if FB ever stops by here, I doubt if my code gets targeted  |
|
|
|
 |
|