From: Dmitry Stogov Date: Tue, 10 Jul 2007 09:11:35 +0000 (+0000) Subject: Fixed preg_replace_callback() with callback defined by array X-Git-Tag: BEFORE_IMPORT_OF_MYSQLND~276 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a49ce8b8fb0f13ebd9260c2cee526e360d68282;p=php Fixed preg_replace_callback() with callback defined by array --- diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index f008c5f34b..b47095caae 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -1422,7 +1422,9 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_callabl } if (is_callable_replace) { - convert_to_text(replace); + if (Z_TYPE_P(replace) != IS_ARRAY) { + convert_to_text(replace); + } if (!zend_is_callable(replace, 0, &callback_name)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Requires argument 2, '%R', to be a valid callback", Z_TYPE(callback_name), Z_UNIVAL(callback_name)); zval_dtor(&callback_name); diff --git a/ext/pcre/tests/bug21732.phpt b/ext/pcre/tests/bug21732.phpt index 3dfc41e19f..7daf1084ab 100644 --- a/ext/pcre/tests/bug21732.phpt +++ b/ext/pcre/tests/bug21732.phpt @@ -27,3 +27,16 @@ array(4) { string(1) "e" } string(4) "yes!" +--UEXPECT-- +bool(false) +array(4) { + [0]=> + unicode(5) "abcde" + [1]=> + unicode(2) "ab" + [2]=> + unicode(2) "cd" + [3]=> + unicode(1) "e" +} +unicode(4) "yes!"