ID: 38018 Updated by: [EMAIL PROTECTED] Reported By: php dot bugs at login dot hedim dot ch -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: FreeBSD PHP Version: 5.1.4 New Comment:
Change your code to this: $var = new Foo; $str = serialize($var); unserialize($str); and voila - no second destructor call. The first destructor is called for the temporary var. Previous Comments: ------------------------------------------------------------------------ [2006-07-05 20:31:32] php dot bugs at login dot hedim dot ch Description: ------------ If __wakeup threw an exception when unserializing an object, __destruct is called on that object. For the same reasons as __destruct is not called if __construct threw an exception (see bug #29368), it should not be called here either. Reproduce code: --------------- class Foo { function __wakeup() { throw new Exception; } function __destruct() { echo "hello from destructor\n"; } } unserialize(serialize(new Foo)); Expected result: ---------------- hello from destructor (from the destructor of the object to be serialized) Actual result: -------------- hello from destructor (from the destructor of the object to be serialized) hello from destructor (from the destructor of the object that fails to unserialize) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38018&edit=1