Couldn't PHP destroy global objects by taking their refcount into account? All objects with refcount=1 are first destroyed, then all objects with refcount=2, and so on... Objects with a same refcount are destroyed in a random "order".
Be carreful, this does not resolve all things :
$source1 = new stdClass ; $source2 = new stdClass ; $source3 = new stdClass ; $refLevel1 = new stdClass ; $refLevel2 = new stdClass ;
$source1->ref = $refLevel1 ; $source2->ref = $refLevel1 ; $source3->ref = $refLevel1 ;
$refLevel1->ref = $refLevel2 ;
We have : refcount of 1 : $source1, $source2 and $source3 refcount of 2 : $refLevel2 ; refcount of 4 : $refLevel1 ;
$refLevel1 as a refcount of 4 but should be destroyed before $refLevel2 (which has a refcount of 2).
What we can do is : + while( there are $vars with refcount of 1 ) { - destruct this variables - if this variables references other vars, decrement their refcount } + then destroy all the rest in random (which have circular dependendencies)
This is NOT the same as destroy refcounts of 1, then refcount of 2, etc.
Anyway I do not know how the engine deals (or can deal) with all that, I only write about theorical ways.
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php