Index: Zend/zend_execute_API.c =================================================================== --- Zend/zend_execute_API.c (revision 308991) +++ Zend/zend_execute_API.c (working copy) @@ -209,7 +209,7 @@ static int zval_call_destructor(zval **zv TSRMLS_DC) /* {{{ */ { - if (Z_TYPE_PP(zv) == IS_OBJECT && Z_REFCOUNT_PP(zv) == 1) { + if (Z_TYPE_PP(zv) == IS_OBJECT) { return ZEND_HASH_APPLY_REMOVE; } else { return ZEND_HASH_APPLY_KEEP; @@ -220,11 +220,7 @@ void shutdown_destructors(TSRMLS_D) /* {{{ */ { zend_try { - int symbols; - do { - symbols = zend_hash_num_elements(&EG(symbol_table)); - zend_hash_reverse_apply(&EG(symbol_table), (apply_func_t) zval_call_destructor TSRMLS_CC); - } while (symbols != zend_hash_num_elements(&EG(symbol_table))); + zend_hash_apply(&EG(symbol_table), (apply_func_t) zval_call_destructor TSRMLS_CC); zend_objects_store_call_destructors(&EG(objects_store) TSRMLS_CC); } zend_catch { /* if we couldn't destruct cleanly, mark all objects as destructed anyway */