test.php:
<?php
eaccelerator_clear();
require_once dirname(__FILE__).'/test_parent.class.php';
require_once dirname(__FILE__).'/test.class.php';
$Test = new Test();
test2.php
<?php
ini_set( 'unserialize_callback_func', 'unserialize_cb' );
function unserialize_cb($classname)
{
require_once dirname(__FILE__).'/test.class.php';
}
$s = 'O:4:"Test":1:{s:4:"test";i:78701;}';
$o = unserialize($s);
var_dump($o);
$o->f();
?>
test.class.php:
<?php
require_once dirname(__FILE__).'/test_parent.class.php';
class Test extends Test_parent
{
function Test()
{
$this->test = rand(0, 100000);
parent::f();
}
}
?>
test_parent.class.php:
<?php
class Test_parent
{
function Test_parent()
{
}
function f()
{
echo '<h2>f()</h2>';
}
}
?>
Reproduce:
1. Call test.php. This will clear the cache.
2. Call test2.php.
Result:
object(Test)#1 (1) { test?=> int(78701) }
Fatal error: Call to undefined method Test::f() in /X/test2.php on line 16
Expected result:
object(Test)#1 (1) { test?=> int(78701) }
f()
The expected result happens, if you clear the file cache and execute test2.php, without calling test.php first.
The error does not occur, if you swap the require statements in test.php and use
require_once dirname(__FILE__).'/test.class.php';
require_once dirname(__FILE__).'/test_parent.class.php';
instead of
require_once dirname(__FILE__).'/test_parent.class.php';
require_once dirname(__FILE__).'/test.class.php';
I've found this, while trying to reproduce ticket:183 and I think it's related at least.
eaccelerator r282, mod_php (PHP_5_2).