From: rueycheng at gmail dot com Operating system: Windows XP PHP version: 5.0.1 PHP Bug Type: Class/Object related Bug description: filesystem functions and object destructor
Description: ------------ Some filesystem functions, like file_put_contents() or fwrite(), don't work properly in the destructor __destruct(). The following scenario may looks a bit weird: it appeared that the file is not overwritten or even created, but PHP does 'read' the content of the imaginary file! If you uncomment the last line of the code, everything would works fine. Thanks. $ diff php.ini php.ini-dist 288c288 < error_reporting = E_ALL --- > error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT 436c436 < include_path = ".;c:\php-5.0.1\PEAR" --- > ;include_path = ".;c:\php\includes" 450c450 < extension_dir = "c:\php-5.0.1\ext" --- > extension_dir = "./" 571,573c571,573 < extension=php_mbstring.dll < extension=php_mcrypt.dll < extension=php_mhash.dll --- > ;extension=php_mbstring.dll > ;extension=php_mcrypt.dll > ;extension=php_mhash.dll 578c578 < extension=php_mysql.dll --- > ;extension=php_mysql.dll Reproduce code: --------------- <? class Bug { private $filename; public function __construct($filename) { $this->filename = $filename; } public function __destruct() { echo "["; file_put_contents($this->filename, 'Gotcha!'); echo file_get_contents($this->filename); echo "]"; } } $bug = new Bug('.bugtest'); //unset($bug); ?> Expected result: ---------------- [Gotcha!] (And the file .bugtest under working directory should be created.) $ cat .bugtest Gotcha! Actual result: -------------- [Gotcha!] $ cat .bugtest cat: .bugtest: No such file or directory -- Edit bug report at http://bugs.php.net/?id=30957&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30957&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30957&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30957&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30957&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30957&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30957&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30957&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30957&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30957&r=support Expected behavior: http://bugs.php.net/fix.php?id=30957&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30957&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30957&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30957&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30957&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30957&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30957&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30957&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30957&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30957&r=mysqlcfg