#31700 [NEW]: explicit destruction of an object not possible
| From: | attibln at gmx dot net | Date: | Wed, 26 Jan 2005 01:51:51 +0000 |
| Subject: | #31700 [NEW]: explicit destruction of an object not possible | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-72823@lists.php.net to get a copy of this message | ||
From: attibln at gmx dot net
Operating system: linux
PHP version: 5.0.3
PHP Bug Type: Class/Object related
Bug description: explicit destruction of an object not possible
Description:
------------
On second call of __destruct() there should be an error message like
"object not existing".
(http://www.php.net/manual/de/language.oop5.decon.php)
"PHP 5 introduces a destructor concept <b>similar to that of other
object-oriented languages, such as Java</b>. The destructor method will be
called as soon as all references to a paticular object are removed or when
the object is <b>explicitly destroyed</b>."
My system:
gentoo 2.4.26-gentoo-r9
apache 2.0.51-r1
PHP Version 5.0.3 / Zend Engine v2.0.3
(php) use flags:
-adabas +apache2 -bcmath -berkdb -birdstep +bzlib -calendar -cdb -cpdflib
+crypt -ctype +curl +curlwrappers -db2 -dba -dbase -dbm -dbmaker -dbx
-debug -dio -empress -empress-bcs -esoob +exif -fam -fdftk -filepro
-flatfile -frontbase -ftp +gd -gd-external -gdbm -gmp -hyperwave-api
-iconv -imap -informix -ingres -inifile -interbase -iodbc +jpeg -kerberos
-ldap -libedit -mcve +memlimit -mhash +mime -ming -mnogosearch -msession
-msql -mssql +mysql -mysqli +ncurses -nis +nls -oci8 -odbc -oracle7
-ovrimos +pcntl -pcre -pfpro +png -posix +postgres -qdbm -readline -recode
-sapdb -sasl +session -shared -sharedmem +simplexml -snmp +soap +sockets
-solid -spell +spl -sqlite +ssl -sybase -sybase-ct -sysvipc +tidy -tiff
+tokenizer -truetype -wddx +xml2 -xmlrpc -xpm +xsl +zlib
Reproduce code:
---------------
<?php
class MyDestructableClass {
function __construct() {
print "<br />In constructor\n";
$this->name = "MyDestructableClass";
}
function __destruct() {
print "<br />Destroying " . $this->name . "\n";
}
}
$obj = new MyDestructableClass();
print( '<br />before destruction' );
$obj->__destruct();
$obj->__destruct();
$obj->__destruct();
print( '<br />before script end' );
?>
Expected result:
----------------
something like:
Fatal error: ... Destruction of not existing object ist not possible! ...
in ... on line ...
Actual result:
--------------
Explicit destruction "not possible".
In other words:
Calling __destruct on an object is possible as often it is done.
--
Edit bug report at http://bugs.php.net/?id=31700&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31700&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31700&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31700&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31700&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31700&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31700&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31700&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31700&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31700&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31700&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=31700&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=31700&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31700&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31700&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31700&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31700&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31700&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31700&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31700&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31700&r=mysqlcfg