#31326 [NEW]: Object Destruction Order

From: Date: Tue, 28 Dec 2004 19:27:19 +0000
Subject: #31326 [NEW]: Object Destruction Order
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-71170@lists.php.net to get a copy of this message
From: sir dot gallahad at gmail dot com Operating system: Linux PHP version: 5.0.2 PHP Bug Type: Zend Engine 2 problem Bug description: Object Destruction Order Description: ------------ First of all. It's not a bug. It's a sugestion to give more stability to the engine. When the Zend Engine reaches the end of a script page it cleans up the classes that have been created. Nowadays it cleans up in the order the classes have been created. I suggest that it would be a safer routine to destroy a class following a heap of objects (first in last out). It would help some nesting routines, not mentioning the memory allocation. Reproduce code: --------------- <? $ident = 0; class Tag { public $aVar; function __construct( $pMe ) { global $ident; $this->aVar = $pMe; echo str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;",$ident)."[".$this->aVar."]<br>"; $ident++; } function __destruct() { global $ident; $ident--; echo str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;",$ident)."[/".$this->aVar."]<br>"; } } $v1 = new Tag("tag1"); $v2 = new Tag("tag2"); $v3 = new Tag("tag3"); echo '<br><br>'; ?> Expected result: ---------------- [tag1] [tag2] [tag3] [/tag3] [/tag2] [/tag1] Actual result: -------------- [tag1] [tag2] [tag3] [/tag1] [/tag2] [/tag3] -- Edit bug report at http://bugs.php.net/?id=31326&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31326&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31326&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31326&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=31326&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=31326&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=31326&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=31326&r=needscript Try newer version: http://bugs.php.net/fix.php?id=31326&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=31326&r=support Expected behavior: http://bugs.php.net/fix.php?id=31326&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=31326&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=31326&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=31326&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31326&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=31326&r=dst IIS Stability: http://bugs.php.net/fix.php?id=31326&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=31326&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=31326&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=31326&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=31326&r=mysqlcfg

« previous php.bugs (#71170) next »