- Fixed bug #37244 (Added strict flag to base64_decode() that enforces
RFC3548 compliance). (Ilia)
- Fixed bug #36949 (invalid internal mysqli objects dtor). (Mike)
+- Fixed bug #36759 (Objects destructors are invoked in wrong order when script
+ is finished). (Dmitry)
- Fixed bug #36630 (umask not reset at the end of the request). (Ilia)
- Fixed bug #35886 (file_get_contents() fails with some
combinations of offset & maxlen). (Nuno)
--- /dev/null
+--TEST--
+Bug #36759 (Objects destructors are invoked in wrong order when script is finished)
+--FILE--
+<?php
+class Foo {
+ private $bar;
+ function __construct($bar) {
+ $this->bar = $bar;
+ }
+ function __destruct() {
+ echo __METHOD__,"\n";
+ unset($this->bar);
+ }
+}
+
+class Bar {
+ function __destruct() {
+ echo __METHOD__,"\n";
+ unset($this->bar);
+ }
+}
+$y = new Bar();
+$x = new Foo($y);
+?>
+--EXPECT--
+Foo::__destruct
+Bar::__destruct
EG(This) = NULL;
}
+static int zval_call_destructor(zval **zv TSRMLS_DC)
+{
+ if (Z_TYPE_PP(zv) == IS_OBJECT && (*zv)->refcount == 1) {
+ return ZEND_HASH_APPLY_REMOVE;
+ } else {
+ return ZEND_HASH_APPLY_KEEP;
+ }
+}
+
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_objects_store_call_destructors(&EG(objects_store) TSRMLS_CC);
} zend_catch {
/* if we couldn't destruct cleanly, mark all objects as destructed anyway */