From: nick at 127tech dot net
Operating system: Debian Linux/2.6
PHP version: 5.0.0RC2
PHP Bug Type: Zend Engine 2 problem
Bug description: __autoload does not work when called from a destructor
Description:
------------
If I define a destructor that needs __autoload to be
called, the require_once call inside of __autoload fails.
If I take the code that failed in the destructor and test
it in another function in the same class, the __autoload
call works fine.
I've noticed that the current working directory is not
correctly set when __autoload is called from the
destructor. It's set to "/", where as my other accesses to
__autoload have a working directory of where my scripts are
located.
I've checked and the file __autoload is trying to
require_once does exist. But even if I set the
full path for the require_once, __autoload fails to work
when called from the destructor.
Explicitly requiring the file with the external class or
causing __autoload to require that class before the
destructor cures the error.
my include_path is set to ".:/usr/local/lib/php". I've
tried placing a copy of my class files in
"/usr/local/lib/php", but that produces the same results.
thanks,
nick
Reproduce code:
---------------
function __autoload( $class )
{
require_once( $class.".php" );
}
class Blah
{
function __destruct()
{
$test = new OutsideClass();
}
}
$inst = new Blah;
Expected result:
----------------
//no output
Actual result:
--------------
Fatal error: __autoload() [function.require]: Failed
opening required 'OutsideClass.php'
(include_path='.:/usr/local/lib/php')
--
Edit bug report at http://bugs.php.net/?id=28566&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28566&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28566&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=28566&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=28566&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=28566&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=28566&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=28566&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=28566&r=support
Expected behavior: http://bugs.php.net/fix.php?id=28566&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=28566&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=28566&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=28566&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28566&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=28566&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=28566&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=28566&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28566&r=float