]> granicus.if.org Git - php/commitdiff
Deprecate /e modifier
authorNikita Popov <nikic@php.net>
Sun, 4 Mar 2012 13:39:12 +0000 (13:39 +0000)
committerNikita Popov <nikic@php.net>
Sun, 4 Mar 2012 13:39:12 +0000 (13:39 +0000)
See https://wiki.php.net/rfc/remove_preg_replace_eval_modifier.

ext/pcre/php_pcre.c
ext/pcre/tests/002.phpt
ext/pcre/tests/004.phpt
tests/lang/bug24403.phpt

index c9d707280cdd3d5c04c6786100deb29b40a29c1f..6b0a41fbedced514d65a2ca3775e6e857fb5c6e9 100644 (file)
@@ -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) {
index 00f68f365104c589cbe4059c8f09060c7a93fd32..fd245633d3487f1bd2a1f69c1ee6a6498bdfdaeb 100644 (file)
@@ -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: 
index b1e95866268a3e9268c7fceaafec7e45ef74211e..1fae406b16b31606c98014f4d3a48c46e6c048f6 100644 (file)
@@ -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
 
 
index fe99257d3d3ae89af426cea17ec41fd235cafc6d..8f4934e7b9ff8e4d83479d8e81bc6f84af47e552 100644 (file)
@@ -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