diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-02-01 14:58:10 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-02-01 15:02:31 +0100 |
commit | e366ceebade0fb3c30d4f99b82a11e5fc879d22e (patch) | |
tree | 91dde58d21dfb7c9bbaf99ddfc0622db5c6f105b /ext | |
parent | 882dcb43f72d14ad52be6f911d398f527d05a0cf (diff) | |
download | php-git-e366ceebade0fb3c30d4f99b82a11e5fc879d22e.tar.gz |
Deprecate mb_ereg_replace with non-string pattern
I'm counting this towards the non-string needle deprecation from
https://wiki.php.net/rfc/deprecations_php_7_3. I wasn't aware that
mb_ereg_replace() is also affected by this issue. It's even more
ridiculous than usual here, because the integer is interpreted as
an ASCII codepoint, even though these are supposed to be multibyte
functions :(
Diffstat (limited to 'ext')
-rw-r--r-- | ext/mbstring/php_mbregex.c | 4 | ||||
-rw-r--r-- | ext/mbstring/tests/bug72994.phpt | 2 | ||||
-rw-r--r-- | ext/mbstring/tests/mb_ereg_replace_variation1.phpt | 40 |
3 files changed, 44 insertions, 2 deletions
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index b0ed0bc8c7..254b0a02c6 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -1049,6 +1049,10 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp arg_pattern = Z_STRVAL_P(arg_pattern_zval); arg_pattern_len = Z_STRLEN_P(arg_pattern_zval); } else { + php_error_docref(NULL, E_DEPRECATED, + "Non-string patterns will be interpreted as strings in the future. " + "Use an explicit chr() call to preserve the current behavior"); + /* FIXME: this code is not multibyte aware! */ convert_to_long_ex(arg_pattern_zval); pat_buf[0] = (char)Z_LVAL_P(arg_pattern_zval); diff --git a/ext/mbstring/tests/bug72994.phpt b/ext/mbstring/tests/bug72994.phpt index 842fdc10b6..5cf5b0ecb0 100644 --- a/ext/mbstring/tests/bug72994.phpt +++ b/ext/mbstring/tests/bug72994.phpt @@ -14,6 +14,8 @@ var_dump($var1); --EXPECTF-- Notice: Undefined variable: var in %s on line %d +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d + Warning: mb_ereg_replace(): mbregex compile err: invalid code point value in %sbug72994.php on line %d bool(false) ===DONE=== diff --git a/ext/mbstring/tests/mb_ereg_replace_variation1.phpt b/ext/mbstring/tests/mb_ereg_replace_variation1.phpt index 6a1231bf8b..e1c6bffa67 100644 --- a/ext/mbstring/tests/mb_ereg_replace_variation1.phpt +++ b/ext/mbstring/tests/mb_ereg_replace_variation1.phpt @@ -100,52 +100,82 @@ echo "Done"; *** Testing mb_ereg_replace() : usage variations *** -- Iteration 1 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" -- Iteration 2 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" -- Iteration 3 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" -- Iteration 4 -- -Warning: mb_ereg_replace(): mbregex compile err: invalid code point value in %smb_ereg_replace_variation1.php on line %d +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d + +Warning: mb_ereg_replace(): mbregex compile err: invalid code point value in %s on line %d bool(false) -- Iteration 5 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" -- Iteration 6 -- -Warning: mb_ereg_replace(): mbregex compile err: invalid code point value in %smb_ereg_replace_variation1.php on line %d +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d + +Warning: mb_ereg_replace(): mbregex compile err: invalid code point value in %s on line %d bool(false) -- Iteration 7 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" -- Iteration 8 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" -- Iteration 9 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" -- Iteration 10 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" -- Iteration 11 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" -- Iteration 12 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" -- Iteration 13 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" -- Iteration 14 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" -- Iteration 15 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" -- Iteration 16 -- @@ -164,11 +194,17 @@ string(10) "string_val" string(10) "string_val" -- Iteration 21 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" -- Iteration 22 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" -- Iteration 23 -- + +Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d string(10) "string_val" Done |