From be202d3d352e82c5d6825772c2709894f2bc4a21 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sun, 4 Mar 2012 13:39:12 +0000 Subject: [PATCH] Deprecate /e modifier See https://wiki.php.net/rfc/remove_preg_replace_eval_modifier. --- ext/pcre/php_pcre.c | 4 ++++ ext/pcre/tests/002.phpt | 2 ++ ext/pcre/tests/004.phpt | 4 +++- tests/lang/bug24403.phpt | 3 ++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index c9d707280c..6b0a41fbed 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -1019,6 +1019,10 @@ PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int sub replace_end = replace + replace_len; } + if (eval) { + php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The /e modifier is deprecated, use preg_replace_callback instead"); + } + /* Calculate the size of the offsets array, and allocate memory for it. */ rc = pcre_fullinfo(pce->re, extra, PCRE_INFO_CAPTURECOUNT, &num_subpats); if (rc < 0) { diff --git a/ext/pcre/tests/002.phpt b/ext/pcre/tests/002.phpt index 00f68f3651..fd245633d3 100644 --- a/ext/pcre/tests/002.phpt +++ b/ext/pcre/tests/002.phpt @@ -34,6 +34,8 @@ string(12) "a${1b${1c${1" Warning: preg_replace(): Compilation failed: missing terminating ] for character class at offset 8 in %s002.php on line 11 NULL +Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in %s on line 12 + Parse error: %s in %s002.php(12) : regexp code on line 1 Fatal error: preg_replace(): Failed evaluating code: diff --git a/ext/pcre/tests/004.phpt b/ext/pcre/tests/004.phpt index b1e9586626..1fae406b16 100644 --- a/ext/pcre/tests/004.phpt +++ b/ext/pcre/tests/004.phpt @@ -16,7 +16,7 @@ var_dump(preg_replace(array('@//.*@S', '@/\*.*\*/@SsUe'), array('', 'preg_replac var_dump(preg_split('/PHP_(?:NAMED_)?(?:FUNCTION|METHOD)\s*\((\w+(?:,\s*\w+)?)\)/S', "PHP_FUNCTION(s, preg_match)\n{\nlalala", -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE)); ?> ---EXPECT-- +--EXPECTF-- int(2) array(2) { [0]=> @@ -117,6 +117,8 @@ array(1) { } } } + +Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in %s on line %d string(9) "hello diff --git a/tests/lang/bug24403.phpt b/tests/lang/bug24403.phpt index fe99257d3d..8f4934e7b9 100644 --- a/tests/lang/bug24403.phpt +++ b/tests/lang/bug24403.phpt @@ -17,4 +17,5 @@ class a } new a(); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in %s on line %d -- 2.40.0