--- /dev/null
+--TEST--
+Reference IDs should be correctly generated when $GLOBALS is serialized
+--FILE--
+<?php
+
+$obj = new stdClass;
+$obj2 = new stdClass;
+$obj2->obj = $obj;
+$s = serialize($GLOBALS);
+$globals = unserialize($s);
+var_dump($obj);
+var_dump($obj2);
+
+?>
+--EXPECT--
+object(stdClass)#1 (0) {
+}
+object(stdClass)#2 (1) {
+ ["obj"]=>
+ object(stdClass)#1 (0) {
+ }
+}
/* we should still add element even if it's not OK,
* since we already wrote the length of the array before */
if (Z_TYPE_P(data) == IS_ARRAY) {
- if (Z_TYPE_P(data) == IS_ARRAY
- && (UNEXPECTED(Z_IS_RECURSIVE_P(data))
- || UNEXPECTED(Z_TYPE_P(struc) == IS_ARRAY && Z_ARR_P(data) == Z_ARR_P(struc)))) {
+ if (UNEXPECTED(Z_IS_RECURSIVE_P(data))
+ || UNEXPECTED(Z_TYPE_P(struc) == IS_ARRAY && Z_ARR_P(data) == Z_ARR_P(struc))) {
+ php_add_var_hash(var_hash, struc);
smart_str_appendl(buf, "N;", 2);
} else {
if (Z_REFCOUNTED_P(data)) {