#36831 [NEW]: Trying to create a file in destructor fails

From: Date: Thu, 23 Mar 2006 11:24:10 +0000
Subject: #36831 [NEW]: Trying to create a file in destructor fails
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-94806@lists.php.net to get a copy of this message
From: felho at avalon dot aut dot bme dot hu Operating system: Windows XP SP2 PHP version: 5.1.2 PHP Bug Type: Class/Object related Bug description: Trying to create a file in destructor fails Description: ------------ In case when an object is freed up at the end of the script file creation will fail in destructor. When I force this before the end of script the file will be created. Reproduce code: --------------- <?php class foo { function __construct() { fopen(date('YmdHim').'.const.txt', 'w'); mail('felho@x.hu', date('YmdHim').'.const.txt', ''); } function __destruct() { fopen(date('YmdHim').'.dest.txt', 'w'); mail('felho@x.hu', date('YmdHim').'.dest.txt', ''); } } $foo = new foo(); //$foo = 1; ?> Expected result: ---------------- Creating two files and sending two mails. Actual result: -------------- Only one file was created but two mails was sent. If you remove the comment on the last line, the second file was created too. -- Edit bug report at http://bugs.php.net/?id=36831&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36831&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36831&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36831&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36831&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36831&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36831&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36831&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36831&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36831&r=support Expected behavior: http://bugs.php.net/fix.php?id=36831&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36831&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36831&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36831&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36831&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36831&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36831&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36831&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36831&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36831&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36831&r=mysqlcfg

« previous php.bugs (#94806) next »