laruence                                 Mon, 03 Oct 2011 17:01:17 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=317672

Log:
Fixed bug #55825, and add test script

Bug: https://bugs.php.net/55825 (Assigned) Missing initial value of static 
locals in trait methods
      
Changed paths:
    U   php/php-src/branches/PHP_5_4/NEWS
    A   php/php-src/branches/PHP_5_4/Zend/tests/bug55825.phpt
    U   php/php-src/branches/PHP_5_4/Zend/zend_compile.c
    A   php/php-src/trunk/Zend/tests/bug55825.phpt
    U   php/php-src/trunk/Zend/zend_compile.c

Modified: php/php-src/branches/PHP_5_4/NEWS
===================================================================
--- php/php-src/branches/PHP_5_4/NEWS   2011-10-03 16:59:17 UTC (rev 317671)
+++ php/php-src/branches/PHP_5_4/NEWS   2011-10-03 17:01:17 UTC (rev 317672)
@@ -12,6 +12,8 @@
     (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

Added: php/php-src/branches/PHP_5_4/Zend/tests/bug55825.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/tests/bug55825.phpt                       
        (rev 0)
+++ php/php-src/branches/PHP_5_4/Zend/tests/bug55825.phpt       2011-10-03 
17:01:17 UTC (rev 317672)
@@ -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

Modified: php/php-src/branches/PHP_5_4/Zend/zend_compile.c
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/zend_compile.c    2011-10-03 16:59:17 UTC 
(rev 317671)
+++ php/php-src/branches/PHP_5_4/Zend/zend_compile.c    2011-10-03 17:01:17 UTC 
(rev 317672)
@@ -3695,7 +3695,7 @@

                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 @@
        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) /* {{{ */
 {

Added: php/php-src/trunk/Zend/tests/bug55825.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/bug55825.phpt                          (rev 0)
+++ php/php-src/trunk/Zend/tests/bug55825.phpt  2011-10-03 17:01:17 UTC (rev 
317672)
@@ -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

Modified: php/php-src/trunk/Zend/zend_compile.c
===================================================================
--- php/php-src/trunk/Zend/zend_compile.c       2011-10-03 16:59:17 UTC (rev 
317671)
+++ php/php-src/trunk/Zend/zend_compile.c       2011-10-03 17:01:17 UTC (rev 
317672)
@@ -3695,7 +3695,7 @@

                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 @@
        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) /* {{{ */
 {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to