From: Andrei Zmievski Date: Wed, 17 Oct 2001 18:20:19 +0000 (+0000) Subject: @- Fixed a bug in preg_replace() that would change the type of the replacement X-Git-Tag: POST_PARAMETER_PARSING_API~95 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a90e5f5a6b00362f9e6e52d1e46e032b8d26143a;p=php @- Fixed a bug in preg_replace() that would change the type of the replacement @ array entries to string. (Andrei) --- diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 381c1b4eed..74caa0f0e9 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -704,7 +704,6 @@ char *php_pcre_replace(char *regex, int regex_len, return NULL; } } else { - convert_to_string(replace_val); replace = Z_STRVAL_P(replace_val); replace_len = Z_STRLEN_P(replace_val); replace_end = replace + replace_len; @@ -906,6 +905,9 @@ static char *php_replace_in_subject(zval *regex, zval *replace, zval **subject, if (Z_TYPE_P(replace) == IS_ARRAY && !is_callable_replace) { /* Get current entry */ if (zend_hash_get_current_data(Z_ARRVAL_P(replace), (void **)&replace_entry) == SUCCESS) { + if (!is_callable_replace) { + convert_to_string_ex(replace_entry); + } replace_value = *replace_entry; zend_hash_move_forward(Z_ARRVAL_P(replace)); } else {