Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7530 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21337 invoked by uid 1010); 4 Feb 2004 10:16:26 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 21208 invoked from network); 4 Feb 2004 10:16:23 -0000 Received: from unknown (HELO mail.zend.com) (192.117.235.230) by pb1.pair.com with SMTP; 4 Feb 2004 10:16:23 -0000 Received: (qmail 18048 invoked from network); 4 Feb 2004 10:16:04 -0000 Received: from localhost (HELO zeev-laptop.zend.com) (127.0.0.1) by localhost with SMTP; 4 Feb 2004 10:16:04 -0000 Reply-To: zeev@zend.com Message-ID: <5.1.0.14.2.20040204115844.04341008@localhost> X-Sender: (Unverified) X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Wed, 04 Feb 2004 12:09:50 +0200 To: internals@lists.php.net Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: New destructors implementation From: andi@zend.com (Andi Gutmans) We've changed the way that objects are destroyed during shutdown to a 2-phase mechanism. First, destructors are called for all of the objects in the store (in no particular order). Afterwards - the object storage and the various symbol tables are destroyed&freed. This has several implications: 1. The dependency problems during shutdown which could cause destructors not to be called under certain circumstances - are gone now. Destructors are always called for all objects, and you can depend on that. 2. A *VERY* important implication is that you cannot, and must not rely in any way on the order of destruction during shutdown. It runs in no particular order. That means that by the time the destructor for your object $foo is called, a reference to some other object $bar may already be post-destruction. Note that it will still be 'intact' and accessible in the sense that if you access it - there won't be crashes. However, if this object does indeed have a destructor, it can be considered semantically wrong to touch this object at this point. 3. The APIs have changed to allow for this new mechanism. Instead of the previous dtor callback, which was supposed to both call the destructor and free the object's storage, there are now two separate callbacks - dtor (call the destructor) and free_storage (guess). Generally, for classes which implement PHP-style objects, you should implement both of these callbacks (though you can probably use the standard dtor callback). For overloaded classes such as SimpleXML, COM, etc. - you will most likely only have to implement the free_storage callback, as there's no destructor per-se. We already went over all the overloaded classes in the php-src CVS and moved most of the dtor callbacks to free_storage. Note that the interface is slightly different between these two callbacks - free_storage doesn't receive the object handle. 4. Last but not least - bug #25541 is now fixed! :) Andi