2008-08-24, 07:23 PM
On MyBB 1.4.1 running with PHP 5.2.5 or 5.2.6 the $lang object seems to be deconstructed before run_shutdown() is called, resulting for example in the task-log displaying the execution time, but no text. Of course only afflicts installations using the PHP shutdown-functionality.
As a fix the run_shutdown() function should reconstruct the object. My idea is to change two files to do that.
a) functions.php, e.g. line 196
b) class_language.php, line 125
The fix above didn't work at first, only after I changed class_language.php, function load(), line 125. Replaced two required_onces by requireds. Apparently php still knows it once loaded the files. Reading them again does no harm, so... here is the changed code:
After both changes the task logging works as expected on 1.4.1 with PHP 5.2.5 and 5.2.6.
Zakkinen
As a fix the run_shutdown() function should reconstruct the object. My idea is to change two files to do that.
a) functions.php, e.g. line 196
// Lang object deconstructed? reconstruct
if(!is_object($lang))
{
require_once MYBB_ROOT."inc/class_language.php";
$lang = new MyLanguage;
$lang->set_path(MYBB_ROOT."inc/languages");
// Load language
$lang->set_language($mybb->settings['bblanguage']);
$lang->load("global");
$lang->load("messages");
}
b) class_language.php, line 125
The fix above didn't work at first, only after I changed class_language.php, function load(), line 125. Replaced two required_onces by requireds. Apparently php still knows it once loaded the files. Reading them again does no harm, so... here is the changed code:
function load($section, $isdatahandler=false, $supress_error=false)
{
// Assign language variables.
// Datahandlers are never in admin lang directory.
if($isdatahandler === true)
{
$this->language = str_replace('/admin', '', $this->language);
}
$lfile = $this->path."/".$this->language."/".$section.".lang.php";
if(file_exists($lfile))
{
// php-shutdown-hack Henrik Zawischa
require $lfile;
// require_once $lfile;
}
elseif(file_exists($this->path."/english/".$section.".lang.php"))
{
// php-shutdown-hack Henrik Zawischa
require $this->path."/english/".$section.".lang.php";
// require_once $this->path."/english/".$section.".lang.php";
}
else
{
if($supress_error != true)
{
die("$lfile does not exist");
}
}
if(is_array($l))
{
foreach($l as $key => $val)
{
if(empty($this->$key) || $this->$key != $val)
{
$this->$key = $val;
}
}
}
}
After both changes the task logging works as expected on 1.4.1 with PHP 5.2.5 and 5.2.6.
Zakkinen