From: Felipe Pena Date: Sat, 26 Jun 2010 17:14:33 +0000 (+0000) Subject: - Fixed bug #52193 (converting closure to array yields empty array) X-Git-Tag: php-5.3.3RC2~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9ea7a70e24bc41cd5981e0fd16a9d7eb8fee6f39;p=php - Fixed bug #52193 (converting closure to array yields empty array) --- diff --git a/NEWS b/NEWS index f08b39d1b4..3e69fec80e 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2010, PHP 5.3.3 RC2 - Implemented FR #51295 (SQLite3::busyTimeout not existing). (Mark) + - Fixed the mail.log ini setting when no filename was given. (Johannes) + +- Fixed bug #52193 (converting closure to array yields empty array). (Felipe) - Fixed bug #52183 (Reflectionfunction reports invalid number of arguments for function aliases). (Felipe) - Fixed bug #52162 (custom request header variables with numbers are removed). diff --git a/Zend/tests/bug52193.phpt b/Zend/tests/bug52193.phpt new file mode 100644 index 0000000000..b4e4b3aab9 --- /dev/null +++ b/Zend/tests/bug52193.phpt @@ -0,0 +1,78 @@ +--TEST-- +Bug #52193 (converting closure to array yields empty array) +--FILE-- + +--EXPECTF-- +array(1) { + [0]=> + int(1) +} +array(0) { +} +array(0) { +} +array(1) { + [0]=> + object(Closure)#1 (0) { + } +} +int(2) +array(1) { + [0]=> + object(Closure)#2 (1) { + ["static"]=> + array(1) { + ["h"]=> + &array(1) { + [0]=> + object(Closure)#1 (0) { + } + } + } + } +} +object(Closure)#2 (1) { + ["static"]=> + array(1) { + ["h"]=> + &array(1) { + [0]=> + object(Closure)#1 (0) { + } + } + } +} +array(1) { + [0]=> + object(Closure)#1 (0) { + } +} +array(2) { + [0]=> + object(Closure)#3 (0) { + } + [1]=> + int(5) +} diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 7ce2e6283a..24a2b1e417 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -30,6 +30,7 @@ #include "zend_multiply.h" #include "zend_strtod.h" #include "zend_exceptions.h" +#include "zend_closures.h" #define LONG_SIGN_MASK (1L << (8*sizeof(long)-1)) @@ -646,7 +647,14 @@ ZEND_API void convert_to_array(zval *op) /* {{{ */ ALLOC_HASHTABLE(ht); zend_hash_init(ht, 0, NULL, ZVAL_PTR_DTOR, 0); - if (Z_OBJ_HT_P(op)->get_properties) { + if (Z_OBJCE_P(op) == zend_ce_closure) { + convert_scalar_to_array(op, IS_ARRAY TSRMLS_CC); + if (Z_TYPE_P(op) == IS_ARRAY) { + zend_hash_destroy(ht); + FREE_HASHTABLE(ht); + return; + } + } else if (Z_OBJ_HT_P(op)->get_properties) { HashTable *obj_ht = Z_OBJ_HT_P(op)->get_properties(op TSRMLS_CC); if (obj_ht) { zend_hash_copy(ht, obj_ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));