From: Moriyoshi Koizumi Date: Fri, 14 Feb 2003 18:42:36 +0000 (+0000) Subject: Fixed bug #22224 (implode changes object references in array) X-Git-Tag: RELEASE_0_5~1012 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b3a8349191d1c29745cd1640c66eafa7d85b12a4;p=php Fixed bug #22224 (implode changes object references in array) Added test case for the bug --- diff --git a/ext/standard/string.c b/ext/standard/string.c index bbdb38abe8..e5788dcf1b 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -835,7 +835,8 @@ PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value) zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), &pos); while (zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **) &tmp, &pos) == SUCCESS) { - convert_to_string_ex(tmp); + SEPARATE_ZVAL(tmp); + convert_to_string(*tmp); smart_str_appendl(&implstr, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); if (++i != numelems) { diff --git a/ext/standard/tests/strings/bug22224.phpt b/ext/standard/tests/strings/bug22224.phpt new file mode 100644 index 0000000000..fea9455654 --- /dev/null +++ b/ext/standard/tests/strings/bug22224.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #22224 (implode changes object references in array) +--INI-- +error_reporting=0 +--FILE-- +&$a, 1=>&$a); +var_dump(implode(",",$arr)); +var_dump($arr) +?> +--EXPECT-- +string(13) "Object,Object" +array(2) { + [0]=> + &object(foo)(0) { + } + [1]=> + &object(foo)(0) { + } +}