]> granicus.if.org Git - php/commitdiff
Fixed bug #30140 (Problem with array in static properties)
authorDmitry Stogov <dmitry@php.net>
Wed, 8 Jun 2005 13:21:01 +0000 (13:21 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 8 Jun 2005 13:21:01 +0000 (13:21 +0000)
NEWS
Zend/tests/bug30140.phpt [new file with mode: 0755]
Zend/zend_execute_API.c

diff --git a/NEWS b/NEWS
index a89f7de0eb70942eb5442080e70e41224c00713a..ac181cd0960b8a1410ae9749424ee9d280d82ae9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -143,6 +143,7 @@ PHP                                                                        NEWS
   array_push()). (Dmitry)
 - Fixed bug #30162 (Catching exception in constructor causes lose of $this).
   (Dmitry)
+- Fixed bug #30140 (Problem with array in static properties). (Dmitry)
 - Fixed bug #30126 (Enhancement for error message for abstract classes). 
   (Marcus)
 - Fixed bug #30080 (Passing array or non array of objects). (Dmitry)
diff --git a/Zend/tests/bug30140.phpt b/Zend/tests/bug30140.phpt
new file mode 100755 (executable)
index 0000000..1dfb835
--- /dev/null
@@ -0,0 +1,30 @@
+--TEST--
+Bug #30140 (Problem with array in static properties)
+--FILE--
+<?php
+class A {
+       public static $test1 = true;
+       public static $test2 = array();
+       public static $test3 = "str";
+}
+
+class B extends A {
+}
+
+A::$test1 = "x";
+A::$test2 = "y";
+A::$test3 = "z";
+var_dump(A::$test1);
+var_dump(A::$test2);
+var_dump(A::$test3);
+var_dump(B::$test1);
+var_dump(B::$test2);
+var_dump(B::$test3);
+?>
+--EXPECT--
+string(1) "x"
+string(1) "y"
+string(1) "z"
+string(1) "x"
+string(1) "y"
+string(1) "z"
index afa26a58854ec892ccf15675d0161a8c9edd3fbe..b26767615a40ce0576df07d4a12aab15ba3f2fb3 100644 (file)
@@ -437,11 +437,13 @@ ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC)
 
        if (p->type == IS_CONSTANT) {
                int refcount;
+               zend_uchar is_ref;
 
-               SEPARATE_ZVAL(pp);
+               SEPARATE_ZVAL_IF_NOT_REF(pp);
                p = *pp;
 
                refcount = p->refcount;
+               is_ref = p->is_ref;
 
                if (!zend_get_constant(p->value.str.val, p->value.str.len, &const_value TSRMLS_CC)) {
                        zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
@@ -458,15 +460,15 @@ ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC)
                        *p = const_value;
                }
 
-               INIT_PZVAL(p);
                p->refcount = refcount;
+               p->is_ref = is_ref;
        } else if (p->type == IS_CONSTANT_ARRAY) {
                zval **element, *new_val;
                char *str_index;
                uint str_index_len;
                ulong num_index;
 
-               SEPARATE_ZVAL(pp);
+               SEPARATE_ZVAL_IF_NOT_REF(pp);
                p = *pp;
                p->type = IS_ARRAY;