Skip to content

Commit 2eb980f

Browse files
committed
IS_REFERENCE with refcount==1 should be handled as ordinal value
1 parent f3b4b16 commit 2eb980f

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Zend/zend_variables.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,12 @@ ZEND_API void _zval_internal_dtor_for_ptr(zval *zvalue ZEND_FILE_LINE_DC)
188188
ZEND_API void zval_add_ref(zval *p)
189189
{
190190
if (Z_REFCOUNTED_P(p)) {
191-
Z_ADDREF_P(p);
191+
//???: autoconversion from reverence to ordinal value
192+
if (Z_ISREF_P(p) && Z_REFCOUNT_P(p) == 1) {
193+
ZVAL_DUP(p, Z_REFVAL_P(p));
194+
} else {
195+
Z_ADDREF_P(p);
196+
}
192197
}
193198
}
194199

ext/standard/var.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ PHPAPI void php_var_dump(zval *struc, int level TSRMLS_DC) /* {{{ */
9797
}
9898

9999
if (Z_TYPE_P(struc) == IS_REFERENCE) {
100-
is_ref = 1;
100+
//??? hide references with refcount==1 (for compatibility)
101+
if (Z_REFCOUNT_P(struc) > 1) {
102+
is_ref = 1;
103+
}
101104
struc = Z_REFVAL_P(struc);
102105
}
103106

@@ -256,7 +259,10 @@ PHPAPI void php_debug_zval_dump(zval *struc, int level TSRMLS_DC) /* {{{ */
256259
}
257260

258261
if (Z_TYPE_P(struc) == IS_REFERENCE) {
259-
is_ref = 1;
262+
//??? hide references with refcount==1 (for compatibility)
263+
if (Z_REFCOUNT_P(struc) > 1) {
264+
is_ref = 1;
265+
}
260266
struc = Z_REFVAL_P(struc);
261267
}
262268

0 commit comments

Comments
 (0)