]> granicus.if.org Git - php/commitdiff
Fixed bug #55825, and add test script
authorXinchen Hui <laruence@php.net>
Mon, 3 Oct 2011 17:01:17 +0000 (17:01 +0000)
committerXinchen Hui <laruence@php.net>
Mon, 3 Oct 2011 17:01:17 +0000 (17:01 +0000)
NEWS
Zend/tests/bug55825.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/NEWS b/NEWS
index 39efbee170ce8c42639232dcd942fd3da43ac81e..456e2335b003ace8ca11d83e3ef25a9a1254b967 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,8 @@ PHP                                                                        NEWS
     (Felipe, Laruence)
   . Fixed bug #55758 (Digest Authenticate missed in 5.4) . (Laruence)
   . Fixed bug #55622 (memory corruption in parse_ini_string). (Pierre)
+  . Fixed bug #55825 (Missing initial value of static locals in trait methods).
+    (Laruence)
 
 - Zlib:
   . Fixed bug #55544 (ob_gzhandler always conflicts with 
diff --git a/Zend/tests/bug55825.phpt b/Zend/tests/bug55825.phpt
new file mode 100644 (file)
index 0000000..23fc933
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+Bug #55825 (Missing initial value of static locals in trait methods)
+--FILE--
+<?php
+trait T1 {
+       public function inc() {
+               static $x=1;
+               echo $x++ . "\n";
+       }
+}
+class C { use T1; }
+$c1 = new C;
+$c1->inc();
+$c1->inc();
+--EXPECT--
+1
+2
index 83de4ea60d182d62b9419858bdd2db8678347464..45c8e6c68d7305bc4483babb81ce3dd862f5bedb 100644 (file)
@@ -3695,7 +3695,7 @@ static void zend_traits_duplicate_function(zend_function *fe, zend_class_entry *
 
                ALLOC_HASHTABLE(tmpHash);
                zend_hash_init(tmpHash, zend_hash_num_elements(fe->op_array.static_variables), NULL, ZVAL_PTR_DTOR, 0);
-               zend_hash_apply_with_arguments(tmpHash TSRMLS_CC, (apply_func_args_t)zval_copy_static_var, 1, fe->op_array.static_variables);
+               zend_hash_apply_with_arguments(fe->op_array.static_variables TSRMLS_CC, (apply_func_args_t)zval_copy_static_var, 1, tmpHash);
 
                fe->op_array.static_variables = tmpHash;
        }
@@ -4101,6 +4101,7 @@ static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{
        zend_hash_graceful_destroy(resulting_table);
        free(resulting_table);
 }
+/* }}} */
 
 static zend_class_entry* find_first_definition(zend_class_entry *ce, size_t current_trait, const char* prop_name, int prop_name_length, ulong prop_hash, zend_class_entry *coliding_ce) /* {{{ */
 {