]> granicus.if.org Git - php/commitdiff
IS_REFERENCE with refcount==1 should be handled as ordinal value
authorDmitry Stogov <dmitry@zend.com>
Thu, 6 Mar 2014 08:37:46 +0000 (12:37 +0400)
committerDmitry Stogov <dmitry@zend.com>
Thu, 6 Mar 2014 08:37:46 +0000 (12:37 +0400)
Zend/zend_variables.c
ext/standard/var.c

index 7fd42b2eaf8dc0f512bd89c8e134b72489cb4bbe..47b07eec79a26c8ce9cc271f72bd6d9e1b572bd5 100644 (file)
@@ -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);
+               }
        }
 }
 
index c84c6515f05f967d388e48c6e3612dda15cadef7..2cd214d86aed388a8090c8c1ecbe433306cbfb9f 100644 (file)
@@ -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);
        }