#37246 [Opn->Bgs]: Cannot write files in __destruct()
| From: | mike@php.net | Date: | Sun, 30 Apr 2006 08:27:00 +0000 |
| Subject: | #37246 [Opn->Bgs]: Cannot write files in __destruct() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-96389@lists.php.net to get a copy of this message | ||
ID: 37246
Updated by: mike@php.net
Reported By: mass at carlsoft dot net
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Kubuntu 5.10
PHP Version: 5.1.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Exactly.
mike@honeybadger:/www/html$ cat destrct.php
<?php
class c {
function __destruct() {
var_dump(realpath("."));
}
}
$c = new c;
Output in browser:
string(1) "/"
Previous Comments:
------------------------------------------------------------------------
[2006-04-30 07:13:10] judas dot iscariote at gmail dot com
...and you get permission denied because at some point of the script
shutdown, apache chdir() to SERVER_ROOT.
------------------------------------------------------------------------
[2006-04-30 06:38:05] judas dot iscariote at gmail dot com
AFAIK this is the expected behaviuor.destructors are called at script
shutdown, and most parts of the engine are already deactivated.
A PHP dev can correct me if Im wrong.
------------------------------------------------------------------------
[2006-04-29 19:23:50] mass at carlsoft dot net
Description:
------------
A warning is thrown when trying to use file_put_contents in the
destructor of a class. It reports that permission was denied, but the
directory and all children are chmod'd to 777. Additionally, I can
write to the file any other time in the script.
Reproduce code:
---------------
class test
{
public function __destruct()
{
file_put_contents('somefile','somedata');
}
}
$foo = new test;
Expected result:
----------------
somefile contain somedata
Actual result:
--------------
Warning with a permission error
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37246&edit=1