MyBB Community Forums

Full Version: Language Fallback Bug
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The load function in class_language.php has fallback logic to use the English language pack if a secondary language is installed and is missing a required language file. This is not working correctly for the AdminCP. If you select a different language for the AdminCP (Home > Preferences > Admin Control Panel Language), the fallback path it generates has /admin/admin twice.
elseif(file_exists($this->path."/".$this->fallback."/".$section.".lang.php"))

{
require_once $this->path."/".$this->fallback."/".$section.".lang.php";
}

Example:
/d1/xxxxxxxx/inc/languages/arabic/admin/user_ougc_awards.lang.php Does Not Exist
/d1/xxxxxxxx/inc/languages/english/admin/admin/user_ougc_awards.lang.php Fallback Location

I fixed this by changing the elseif to the code below.
elseif(file_exists($this->path."/".str_replace("/admin/admin", "/admin", $this->fallback)."/".$section.".lang.php"))
{
require_once $this->path."/".str_replace("/admin/admin", "/admin", $this->fallback)."/".$section.".lang.php";
}

I did a quick search on the forums and do not see this logged as an issue anywhere. I installed a clean copy of MyBB 1.8.6 with the OUGC Awards plugin to ensure it was not an existing plugin/modification causing the problem.
This only happens if set_language is called more than once:
			$this->fallback = $this->fallback."/{$area}";
So that would indicate that it's a problem with the plugins? It doesn't seem to be any plugin in particular, many are doing it. I just tested it using the core language files and it appears to be working correctly there which agrees with your point.
I'm quite sure setting the language twice on a page is not wrong and it's done several times in the core to send PMs/Emails/etc. (not in ACP though). A bug or not (I'd say it definitely is), preventing it with a simple substr() conditional, additional boolean check or anything similar wouldn't be bad.