From 0c98f51c8429b886dceee6c7ae003f1245727b2e Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 9 Jul 2016 16:19:16 +0200 Subject: [PATCH] Implement RFC "Deprecate mb_ereg_replace eval option" has been accepted, so we implement it. --- NEWS | 3 +++ UPGRADING | 2 ++ ext/mbstring/php_mbregex.c | 3 +++ ext/mbstring/tests/bug43301.phpt | 2 ++ ext/mbstring/tests/bug72164.phpt | 3 ++- 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 232d345dff..c28a440c7e 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,9 @@ PHP NEWS . Fixed bug #71745 (FILTER_FLAG_NO_RES_RANGE does not cover whole 127.0.0.0/8 range). (bugs dot php dot net at majkl578 dot cz) +- Mbstring: + . Deprecated mb_ereg_replace() eval option. (Rouven Weßling, cmb) + - PDO_pgsql: . Fixed bug #70313 (PDO statement fails to throw exception). (Matteo) . Fixed bug #72570 (Segmentation fault when binding parameters on a query diff --git a/UPGRADING b/UPGRADING index 0362e1c80d..8102506624 100644 --- a/UPGRADING +++ b/UPGRADING @@ -100,6 +100,8 @@ PHP 7.1 UPGRADE NOTES 4. Deprecated Functionality ======================================== +- 'e' option of mb_ereg_replace() and mb_eregi_replace(). + ======================================== 5. Changed Functions ======================================== diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 5af7eb15c6..b427980430 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -855,6 +855,9 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp syntax = MBREX(regex_default_syntax); } } + if (eval && !is_callable) { + php_error_docref(NULL, E_DEPRECATED, "The 'e' option is deprecated, use mb_ereg_replace_callback instead"); + } if (Z_TYPE_P(arg_pattern_zval) == IS_STRING) { arg_pattern = Z_STRVAL_P(arg_pattern_zval); arg_pattern_len = Z_STRLEN_P(arg_pattern_zval); diff --git a/ext/mbstring/tests/bug43301.phpt b/ext/mbstring/tests/bug43301.phpt index 9c629ec38c..f209bd7554 100644 --- a/ext/mbstring/tests/bug43301.phpt +++ b/ext/mbstring/tests/bug43301.phpt @@ -15,6 +15,8 @@ echo mb_ereg_replace($ptr,'$1',$txt,'e'); ?> --EXPECTF-- +Deprecated: mb_ereg_replace(): The 'e' option is deprecated, use mb_ereg_replace_callback instead in %s%ebug43301.php on line %d + Fatal error: Uncaught ParseError: syntax error, unexpected '1' (T_LNUMBER), expecting variable (T_VARIABLE) or '{' or '$' in %sbug43301.php(%d) : mbregex replace:1 Stack trace: #0 %sbug43301.php(%d): mb_ereg_replace('hello', '$1', 'hello, I have g...', 'e') diff --git a/ext/mbstring/tests/bug72164.phpt b/ext/mbstring/tests/bug72164.phpt index bd58f7e5a5..8666447e7a 100644 --- a/ext/mbstring/tests/bug72164.phpt +++ b/ext/mbstring/tests/bug72164.phpt @@ -10,5 +10,6 @@ $var3 = NULL; $var8 = mbereg_replace($var2,$var3,$var3,$var0); var_dump($var8); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: mbereg_replace(): The 'e' option is deprecated, use mb_ereg_replace_callback instead in %s%ebug72164.php on line %d string(0) "" -- 2.40.0