From: Dmitry Stogov Date: Thu, 6 Mar 2014 08:37:46 +0000 (+0400) Subject: IS_REFERENCE with refcount==1 should be handled as ordinal value X-Git-Tag: POST_PHPNG_MERGE~412^2~408^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2eb980f614ab59aa8f632ae5a70f719f34e8410f;p=php IS_REFERENCE with refcount==1 should be handled as ordinal value --- diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c index 7fd42b2eaf..47b07eec79 100644 --- a/Zend/zend_variables.c +++ b/Zend/zend_variables.c @@ -188,7 +188,12 @@ ZEND_API void _zval_internal_dtor_for_ptr(zval *zvalue ZEND_FILE_LINE_DC) ZEND_API void zval_add_ref(zval *p) { if (Z_REFCOUNTED_P(p)) { - Z_ADDREF_P(p); +//???: autoconversion from reverence to ordinal value + if (Z_ISREF_P(p) && Z_REFCOUNT_P(p) == 1) { + ZVAL_DUP(p, Z_REFVAL_P(p)); + } else { + Z_ADDREF_P(p); + } } } diff --git a/ext/standard/var.c b/ext/standard/var.c index c84c6515f0..2cd214d86a 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -97,7 +97,10 @@ PHPAPI void php_var_dump(zval *struc, int level TSRMLS_DC) /* {{{ */ } if (Z_TYPE_P(struc) == IS_REFERENCE) { - is_ref = 1; +//??? hide references with refcount==1 (for compatibility) + if (Z_REFCOUNT_P(struc) > 1) { + is_ref = 1; + } struc = Z_REFVAL_P(struc); } @@ -256,7 +259,10 @@ PHPAPI void php_debug_zval_dump(zval *struc, int level TSRMLS_DC) /* {{{ */ } if (Z_TYPE_P(struc) == IS_REFERENCE) { - is_ref = 1; +//??? hide references with refcount==1 (for compatibility) + if (Z_REFCOUNT_P(struc) > 1) { + is_ref = 1; + } struc = Z_REFVAL_P(struc); }