Remove mbstring.func_overload

Deprecated in PHP 7.2 as part of
https://wiki.php.net/rfc/deprecations_php_7_2.
This commit is contained in:
Nikita Popov 2019-01-28 13:13:24 +01:00
parent 920b4b249f
commit 331e56ce38
16 changed files with 9 additions and 379 deletions

View file

@ -3169,9 +3169,7 @@ int zend_compile_func_strlen(znode *result, zend_ast_list *args) /* {{{ */
{ {
znode arg_node; znode arg_node;
if ((CG(compiler_options) & ZEND_COMPILE_NO_BUILTIN_STRLEN) if (args->children != 1) {
|| args->children != 1
) {
return FAILURE; return FAILURE;
} }

View file

@ -1035,9 +1035,6 @@ END_EXTERN_C()
/* disable constant substitution at compile-time */ /* disable constant substitution at compile-time */
#define ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION (1<<5) #define ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION (1<<5)
/* disable usage of builtin instruction for strlen() */
#define ZEND_COMPILE_NO_BUILTIN_STRLEN (1<<6)
/* disable substitution of persistent constants at compile-time */ /* disable substitution of persistent constants at compile-time */
#define ZEND_COMPILE_NO_PERSISTENT_CONSTANT_SUBSTITUTION (1<<7) #define ZEND_COMPILE_NO_PERSISTENT_CONSTANT_SUBSTITUTION (1<<7)

View file

@ -174,25 +174,6 @@ static const php_mb_nls_ident_list php_mb_default_identify_list[] = {
/* }}} */ /* }}} */
/* {{{ mb_overload_def mb_ovld[] */
static const struct mb_overload_def mb_ovld[] = {
{MB_OVERLOAD_MAIL, "mail", "mb_send_mail", "mb_orig_mail"},
{MB_OVERLOAD_STRING, "strlen", "mb_strlen", "mb_orig_strlen"},
{MB_OVERLOAD_STRING, "strpos", "mb_strpos", "mb_orig_strpos"},
{MB_OVERLOAD_STRING, "strrpos", "mb_strrpos", "mb_orig_strrpos"},
{MB_OVERLOAD_STRING, "stripos", "mb_stripos", "mb_orig_stripos"},
{MB_OVERLOAD_STRING, "strripos", "mb_strripos", "mb_orig_strripos"},
{MB_OVERLOAD_STRING, "strstr", "mb_strstr", "mb_orig_strstr"},
{MB_OVERLOAD_STRING, "strrchr", "mb_strrchr", "mb_orig_strrchr"},
{MB_OVERLOAD_STRING, "stristr", "mb_stristr", "mb_orig_stristr"},
{MB_OVERLOAD_STRING, "substr", "mb_substr", "mb_orig_substr"},
{MB_OVERLOAD_STRING, "strtolower", "mb_strtolower", "mb_orig_strtolower"},
{MB_OVERLOAD_STRING, "strtoupper", "mb_strtoupper", "mb_orig_strtoupper"},
{MB_OVERLOAD_STRING, "substr_count", "mb_substr_count", "mb_orig_substr_count"},
{0, NULL, NULL, NULL}
};
/* }}} */
/* {{{ arginfo */ /* {{{ arginfo */
ZEND_BEGIN_ARG_INFO_EX(arginfo_mb_language, 0, 0, 0) ZEND_BEGIN_ARG_INFO_EX(arginfo_mb_language, 0, 0, 0)
ZEND_ARG_INFO(0, language) ZEND_ARG_INFO(0, language)
@ -1486,8 +1467,6 @@ PHP_INI_BEGIN()
PHP_INI_ENTRY("mbstring.http_output", NULL, PHP_INI_ALL, OnUpdate_mbstring_http_output) PHP_INI_ENTRY("mbstring.http_output", NULL, PHP_INI_ALL, OnUpdate_mbstring_http_output)
STD_PHP_INI_ENTRY("mbstring.internal_encoding", NULL, PHP_INI_ALL, OnUpdate_mbstring_internal_encoding, internal_encoding_name, zend_mbstring_globals, mbstring_globals) STD_PHP_INI_ENTRY("mbstring.internal_encoding", NULL, PHP_INI_ALL, OnUpdate_mbstring_internal_encoding, internal_encoding_name, zend_mbstring_globals, mbstring_globals)
PHP_INI_ENTRY("mbstring.substitute_character", NULL, PHP_INI_ALL, OnUpdate_mbstring_substitute_character) PHP_INI_ENTRY("mbstring.substitute_character", NULL, PHP_INI_ALL, OnUpdate_mbstring_substitute_character)
STD_PHP_INI_ENTRY("mbstring.func_overload", "0",
PHP_INI_SYSTEM, OnUpdateLong, func_overload, zend_mbstring_globals, mbstring_globals)
STD_PHP_INI_BOOLEAN("mbstring.encoding_translation", "0", STD_PHP_INI_BOOLEAN("mbstring.encoding_translation", "0",
PHP_INI_SYSTEM | PHP_INI_PERDIR, PHP_INI_SYSTEM | PHP_INI_PERDIR,
@ -1535,7 +1514,6 @@ ZEND_TSRMLS_CACHE_UPDATE();
mbstring_globals->current_filter_illegal_mode = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR; mbstring_globals->current_filter_illegal_mode = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
mbstring_globals->current_filter_illegal_substchar = 0x3f; /* '?' */ mbstring_globals->current_filter_illegal_substchar = 0x3f; /* '?' */
mbstring_globals->illegalchars = 0; mbstring_globals->illegalchars = 0;
mbstring_globals->func_overload = 0;
mbstring_globals->encoding_translation = 0; mbstring_globals->encoding_translation = 0;
mbstring_globals->strict_detection = 0; mbstring_globals->strict_detection = 0;
mbstring_globals->outconv = NULL; mbstring_globals->outconv = NULL;
@ -1584,10 +1562,6 @@ ZEND_TSRMLS_CACHE_UPDATE();
sapi_register_post_entries(mbstr_post_entries); sapi_register_post_entries(mbstr_post_entries);
} }
REGISTER_LONG_CONSTANT("MB_OVERLOAD_MAIL", MB_OVERLOAD_MAIL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MB_OVERLOAD_STRING", MB_OVERLOAD_STRING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MB_OVERLOAD_REGEX", MB_OVERLOAD_REGEX, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MB_CASE_UPPER", PHP_UNICODE_CASE_UPPER, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MB_CASE_UPPER", PHP_UNICODE_CASE_UPPER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MB_CASE_LOWER", PHP_UNICODE_CASE_LOWER, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MB_CASE_LOWER", PHP_UNICODE_CASE_LOWER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MB_CASE_TITLE", PHP_UNICODE_CASE_TITLE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MB_CASE_TITLE", PHP_UNICODE_CASE_TITLE, CONST_CS | CONST_PERSISTENT);
@ -1613,39 +1587,6 @@ ZEND_TSRMLS_CACHE_UPDATE();
php_mb_rfc1867_getword_conf, php_mb_rfc1867_getword_conf,
php_mb_rfc1867_basename); php_mb_rfc1867_basename);
/* override original function (deprecated). */
if (MBSTRG(func_overload)){
zend_function *func, *orig;
const struct mb_overload_def *p;
zend_string *str;
p = &(mb_ovld[0]);
while (p->type > 0) {
if ((MBSTRG(func_overload) & p->type) == p->type &&
!zend_hash_str_exists(CG(function_table), p->save_func, strlen(p->save_func))
) {
func = zend_hash_str_find_ptr(CG(function_table), p->ovld_func, strlen(p->ovld_func));
if ((orig = zend_hash_str_find_ptr(CG(function_table), p->orig_func, strlen(p->orig_func))) == NULL) {
php_error_docref("ref.mbstring", E_WARNING, "mbstring couldn't find function %s.", p->orig_func);
return FAILURE;
} else {
ZEND_ASSERT(orig->type == ZEND_INTERNAL_FUNCTION);
str = zend_string_init_interned(p->save_func, strlen(p->save_func), 1);
zend_hash_add_mem(CG(function_table), str, orig, sizeof(zend_internal_function));
zend_string_release_ex(str, 1);
function_add_ref(orig);
str = zend_string_init_interned(p->orig_func, strlen(p->orig_func), 1);
zend_hash_update_mem(CG(function_table), str, func, sizeof(zend_internal_function));
zend_string_release_ex(str, 1);
function_add_ref(func);
}
}
p++;
}
}
return SUCCESS; return SUCCESS;
} }
/* }}} */ /* }}} */
@ -1653,24 +1594,6 @@ ZEND_TSRMLS_CACHE_UPDATE();
/* {{{ PHP_MSHUTDOWN_FUNCTION(mbstring) */ /* {{{ PHP_MSHUTDOWN_FUNCTION(mbstring) */
PHP_MSHUTDOWN_FUNCTION(mbstring) PHP_MSHUTDOWN_FUNCTION(mbstring)
{ {
/* clear overloaded function. */
if (MBSTRG(func_overload)){
const struct mb_overload_def *p;
zend_function *orig;
p = &(mb_ovld[0]);
while (p->type > 0) {
if ((MBSTRG(func_overload) & p->type) == p->type &&
(orig = zend_hash_str_find_ptr(CG(function_table), p->save_func, strlen(p->save_func)))) {
zend_hash_str_update_mem(CG(function_table), p->orig_func, strlen(p->orig_func), orig, sizeof(zend_internal_function));
function_add_ref(orig);
zend_hash_str_del(CG(function_table), p->save_func, strlen(p->save_func));
}
p++;
}
}
UNREGISTER_INI_ENTRIES(); UNREGISTER_INI_ENTRIES();
zend_multibyte_restore_functions(); zend_multibyte_restore_functions();
@ -1695,12 +1618,6 @@ PHP_RINIT_FUNCTION(mbstring)
php_mb_populate_current_detect_order_list(); php_mb_populate_current_detect_order_list();
/* override original function. */
if (MBSTRG(func_overload)){
zend_error(E_DEPRECATED, "The mbstring.func_overload directive is deprecated");
CG(compiler_options) |= ZEND_COMPILE_NO_BUILTIN_STRLEN;
}
#if HAVE_MBREGEX #if HAVE_MBREGEX
PHP_RINIT(mb_regex) (INIT_FUNC_ARGS_PASSTHRU); PHP_RINIT(mb_regex) (INIT_FUNC_ARGS_PASSTHRU);
#endif #endif
@ -2782,11 +2699,6 @@ PHP_FUNCTION(mb_substr)
real_len = 0; real_len = 0;
} }
if (((MBSTRG(func_overload) & MB_OVERLOAD_STRING) == MB_OVERLOAD_STRING)
&& (real_from > mbfl_strlen(&string))) {
RETURN_FALSE;
}
ret = mbfl_substr(&string, &result, real_from, real_len); ret = mbfl_substr(&string, &result, real_from, real_len);
if (NULL == ret) { if (NULL == ret) {
RETURN_FALSE; RETURN_FALSE;
@ -4411,8 +4323,7 @@ PHP_FUNCTION(mb_get_info)
size_t typ_len; size_t typ_len;
size_t n; size_t n;
char *name; char *name;
const struct mb_overload_def *over_func; zval row;
zval row1, row2;
const mbfl_language *lang = mbfl_no2language(MBSTRG(language)); const mbfl_language *lang = mbfl_no2language(MBSTRG(language));
const mbfl_encoding **entry; const mbfl_encoding **entry;
@ -4434,20 +4345,6 @@ PHP_FUNCTION(mb_get_info)
if ((name = (char *)zend_ini_string("mbstring.http_output_conv_mimetypes", sizeof("mbstring.http_output_conv_mimetypes") - 1, 0)) != NULL) { if ((name = (char *)zend_ini_string("mbstring.http_output_conv_mimetypes", sizeof("mbstring.http_output_conv_mimetypes") - 1, 0)) != NULL) {
add_assoc_string(return_value, "http_output_conv_mimetypes", name); add_assoc_string(return_value, "http_output_conv_mimetypes", name);
} }
add_assoc_long(return_value, "func_overload", MBSTRG(func_overload));
if (MBSTRG(func_overload)){
over_func = &(mb_ovld[0]);
array_init(&row1);
while (over_func->type > 0) {
if ((MBSTRG(func_overload) & over_func->type) == over_func->type ) {
add_assoc_string(&row1, over_func->orig_func, over_func->ovld_func);
}
over_func++;
}
add_assoc_zval(return_value, "func_overload_list", &row1);
} else {
add_assoc_string(return_value, "func_overload_list", "no overload");
}
if (lang != NULL) { if (lang != NULL) {
if ((name = (char *)mbfl_no_encoding2name(lang->mail_charset)) != NULL) { if ((name = (char *)mbfl_no_encoding2name(lang->mail_charset)) != NULL) {
add_assoc_string(return_value, "mail_charset", name); add_assoc_string(return_value, "mail_charset", name);
@ -4472,12 +4369,12 @@ PHP_FUNCTION(mb_get_info)
entry = MBSTRG(current_detect_order_list); entry = MBSTRG(current_detect_order_list);
if (n > 0) { if (n > 0) {
size_t i; size_t i;
array_init(&row2); array_init(&row);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
add_next_index_string(&row2, (*entry)->name); add_next_index_string(&row, (*entry)->name);
entry++; entry++;
} }
add_assoc_zval(return_value, "detect_order", &row2); add_assoc_zval(return_value, "detect_order", &row);
} }
if (MBSTRG(current_filter_illegal_mode) == MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE) { if (MBSTRG(current_filter_illegal_mode) == MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE) {
add_assoc_string(return_value, "substitute_character", "none"); add_assoc_string(return_value, "substitute_character", "none");
@ -4509,21 +4406,6 @@ PHP_FUNCTION(mb_get_info)
if ((name = (char *)zend_ini_string("mbstring.http_output_conv_mimetypes", sizeof("mbstring.http_output_conv_mimetypes") - 1, 0)) != NULL) { if ((name = (char *)zend_ini_string("mbstring.http_output_conv_mimetypes", sizeof("mbstring.http_output_conv_mimetypes") - 1, 0)) != NULL) {
RETVAL_STRING(name); RETVAL_STRING(name);
} }
} else if (!strcasecmp("func_overload", typ)) {
RETVAL_LONG(MBSTRG(func_overload));
} else if (!strcasecmp("func_overload_list", typ)) {
if (MBSTRG(func_overload)){
over_func = &(mb_ovld[0]);
array_init(return_value);
while (over_func->type > 0) {
if ((MBSTRG(func_overload) & over_func->type) == over_func->type ) {
add_assoc_string(return_value, over_func->orig_func, over_func->ovld_func);
}
over_func++;
}
} else {
RETVAL_STRING("no overload");
}
} else if (!strcasecmp("mail_charset", typ)) { } else if (!strcasecmp("mail_charset", typ)) {
if (lang != NULL && (name = (char *)mbfl_no_encoding2name(lang->mail_charset)) != NULL) { if (lang != NULL && (name = (char *)mbfl_no_encoding2name(lang->mail_charset)) != NULL) {
RETVAL_STRING(name); RETVAL_STRING(name);

View file

@ -155,7 +155,6 @@ ZEND_BEGIN_MODULE_GLOBALS(mbstring)
int filter_illegal_substchar; int filter_illegal_substchar;
int current_filter_illegal_mode; int current_filter_illegal_mode;
int current_filter_illegal_substchar; int current_filter_illegal_substchar;
zend_long func_overload;
enum mbfl_no_language language; enum mbfl_no_language language;
zend_bool encoding_translation; zend_bool encoding_translation;
zend_bool strict_detection; zend_bool strict_detection;
@ -169,17 +168,6 @@ ZEND_BEGIN_MODULE_GLOBALS(mbstring)
const mbfl_encoding *last_used_encoding; const mbfl_encoding *last_used_encoding;
ZEND_END_MODULE_GLOBALS(mbstring) ZEND_END_MODULE_GLOBALS(mbstring)
#define MB_OVERLOAD_MAIL 1
#define MB_OVERLOAD_STRING 2
#define MB_OVERLOAD_REGEX 4
struct mb_overload_def {
int type;
char *orig_func;
char *ovld_func;
char *save_func;
};
#define MBSTRG(v) ZEND_MODULE_GLOBALS_ACCESSOR(mbstring, v) #define MBSTRG(v) ZEND_MODULE_GLOBALS_ACCESSOR(mbstring, v)
#if defined(ZTS) && defined(COMPILE_DL_MBSTRING) #if defined(ZTS) && defined(COMPILE_DL_MBSTRING)

View file

@ -1,25 +0,0 @@
--TEST--
Bug #52931 (strripos not overloaded with function overloading enabled)
--SKIPIF--
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--INI--
mbstring.func_overload = 7
mbstring.internal_encoding = utf-8
--FILE--
<?php
$string = '<body>Umlauttest öüä</body>';
var_dump(strlen($string));
var_dump(mb_strlen($string));
var_dump(strripos($string, '</body>'));
var_dump(mb_strripos($string, '</body>'));
?>
--EXPECT--
Deprecated: The mbstring.func_overload directive is deprecated in Unknown on line 0
int(27)
int(27)
int(20)
int(20)

View file

@ -9,7 +9,6 @@ mbstring.internal_encoding=UTF-8
mbstring.http_input=ISO-8859-1 mbstring.http_input=ISO-8859-1
mbstring.http_output=ISO-8859-15 mbstring.http_output=ISO-8859-15
mbstring.http_output_conv_mimetypes=abc mbstring.http_output_conv_mimetypes=abc
mbstring.func_overload=2
mbstring.detect_order=UTF-8,ISO-8859-15,ISO-8859-1,ASCII mbstring.detect_order=UTF-8,ISO-8859-15,ISO-8859-1,ASCII
mbstring.substitute_character=123 mbstring.substitute_character=123
mbstring.strict_detection=1 mbstring.strict_detection=1
@ -24,8 +23,7 @@ foreach (array_keys($result) as $key) {
} }
?> ?>
--EXPECT-- --EXPECT--
Deprecated: The mbstring.func_overload directive is deprecated in Unknown on line 0 array(13) {
array(15) {
["internal_encoding"]=> ["internal_encoding"]=>
string(5) "UTF-8" string(5) "UTF-8"
["http_input"]=> ["http_input"]=>
@ -34,35 +32,6 @@ array(15) {
string(11) "ISO-8859-15" string(11) "ISO-8859-15"
["http_output_conv_mimetypes"]=> ["http_output_conv_mimetypes"]=>
string(3) "abc" string(3) "abc"
["func_overload"]=>
int(2)
["func_overload_list"]=>
array(12) {
["strlen"]=>
string(9) "mb_strlen"
["strpos"]=>
string(9) "mb_strpos"
["strrpos"]=>
string(10) "mb_strrpos"
["stripos"]=>
string(10) "mb_stripos"
["strripos"]=>
string(11) "mb_strripos"
["strstr"]=>
string(9) "mb_strstr"
["strrchr"]=>
string(10) "mb_strrchr"
["stristr"]=>
string(10) "mb_stristr"
["substr"]=>
string(9) "mb_substr"
["strtolower"]=>
string(13) "mb_strtolower"
["strtoupper"]=>
string(13) "mb_strtoupper"
["substr_count"]=>
string(15) "mb_substr_count"
}
["mail_charset"]=> ["mail_charset"]=>
string(11) "ISO-2022-KR" string(11) "ISO-2022-KR"
["mail_header_encoding"]=> ["mail_header_encoding"]=>
@ -99,60 +68,6 @@ string(11) "ISO-8859-15"
string(11) "ISO-8859-15" string(11) "ISO-8859-15"
string(3) "abc" string(3) "abc"
string(3) "abc" string(3) "abc"
int(2)
int(2)
array(12) {
["strlen"]=>
string(9) "mb_strlen"
["strpos"]=>
string(9) "mb_strpos"
["strrpos"]=>
string(10) "mb_strrpos"
["stripos"]=>
string(10) "mb_stripos"
["strripos"]=>
string(11) "mb_strripos"
["strstr"]=>
string(9) "mb_strstr"
["strrchr"]=>
string(10) "mb_strrchr"
["stristr"]=>
string(10) "mb_stristr"
["substr"]=>
string(9) "mb_substr"
["strtolower"]=>
string(13) "mb_strtolower"
["strtoupper"]=>
string(13) "mb_strtoupper"
["substr_count"]=>
string(15) "mb_substr_count"
}
array(12) {
["strlen"]=>
string(9) "mb_strlen"
["strpos"]=>
string(9) "mb_strpos"
["strrpos"]=>
string(10) "mb_strrpos"
["stripos"]=>
string(10) "mb_stripos"
["strripos"]=>
string(11) "mb_strripos"
["strstr"]=>
string(9) "mb_strstr"
["strrchr"]=>
string(10) "mb_strrchr"
["stristr"]=>
string(10) "mb_stristr"
["substr"]=>
string(9) "mb_substr"
["strtolower"]=>
string(13) "mb_strtolower"
["strtoupper"]=>
string(13) "mb_strtoupper"
["substr_count"]=>
string(15) "mb_substr_count"
}
string(11) "ISO-2022-KR" string(11) "ISO-2022-KR"
string(11) "ISO-2022-KR" string(11) "ISO-2022-KR"
string(6) "BASE64" string(6) "BASE64"

View file

@ -6,8 +6,6 @@ extension_loaded('mbstring') or die('skip mbstring not available');
extension_loaded('pcre') or die('skip pcre not available'); extension_loaded('pcre') or die('skip pcre not available');
function_exists('mb_split') or die("skip mb_split() is not available in this build"); function_exists('mb_split') or die("skip mb_split() is not available in this build");
?> ?>
--INI--
mbstring.func_overload=0
--FILE-- --FILE--
<?php <?php
mb_regex_set_options( '' ); mb_regex_set_options( '' );

View file

@ -2,8 +2,6 @@
mb_strlen() mb_strlen()
--SKIPIF-- --SKIPIF--
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> <?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--INI--
mbstring.func_overload=0
--FILE-- --FILE--
<?php <?php
// TODO: Add more encodings // TODO: Add more encodings

View file

@ -4,7 +4,6 @@ mb_substr()
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> <?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--INI-- --INI--
output_handler= output_handler=
mbstring.func_overload=0
--FILE-- --FILE--
<?php <?php
// TODO: Add more encodings // TODO: Add more encodings

View file

@ -1,23 +0,0 @@
--TEST--
Function overloading test 1
--SKIPIF--
<?php
extension_loaded('mbstring') or die('skip mbstring not available');
?>
--INI--
output_handler=
mbstring.func_overload=7
mbstring.internal_encoding=EUC-JP
--FILE--
<?php
echo mb_internal_encoding()."\n";
$ngchars = array('能','表','蚕','ソ');
$str = '元禄養蚕會社詐欺表現能力表示噂免停暴力貼付構文圭子予知饅頭ソファー';
var_dump(strlen($str));
var_dump(mb_strlen($str));
--EXPECT--
Deprecated: The mbstring.func_overload directive is deprecated in Unknown on line 0
EUC-JP
int(33)
int(33)

View file

@ -1,34 +0,0 @@
--TEST--
Function overloading test 2
--SKIPIF--
<?php
extension_loaded('mbstring') or die('skip mbstring not available');
if (!function_exists("mb_ereg_replace")) {
die('skip mb_ereg_replace() function is not available.');
}
?>
--INI--
output_handler=
mbstring.func_overload=7
mbstring.internal_encoding=EUC-JP
--FILE--
<?php
echo mb_internal_encoding()."\n";
$ngchars = array('能','表','蚕','ソ');
$str = '元禄養蚕會社詐欺表現能力表示噂免停暴力貼付構文圭子予知饅頭ソファー';
$converted_str = mb_convert_encoding($str, 'Shift_JIS');
mb_regex_encoding('Shift_JIS');
foreach($ngchars as $c) {
$c = mb_convert_encoding($c, 'Shift_JIS');
$replaced = mb_convert_encoding(str_replace($c, '!!', $converted_str), mb_internal_encoding(), 'Shift_JIS');
var_dump(strpos($replaced, '!!'));
}
?>
--EXPECT--
Deprecated: The mbstring.func_overload directive is deprecated in Unknown on line 0
EUC-JP
int(10)
int(8)
int(3)
int(29)

View file

@ -834,8 +834,7 @@ static inline int ct_eval_func_call(
} else if (zend_string_equals_literal(name, "strpos")) { } else if (zend_string_equals_literal(name, "strpos")) {
if (Z_TYPE_P(args[0]) != IS_STRING if (Z_TYPE_P(args[0]) != IS_STRING
|| Z_TYPE_P(args[1]) != IS_STRING || Z_TYPE_P(args[1]) != IS_STRING
|| !Z_STRLEN_P(args[1]) || !Z_STRLEN_P(args[1])) {
|| (CG(compiler_options) & ZEND_COMPILE_NO_BUILTIN_STRLEN)) {
return FAILURE; return FAILURE;
} }
/* pass */ /* pass */
@ -914,8 +913,7 @@ static inline int ct_eval_func_call(
/* pass */ /* pass */
} else if (zend_string_equals_literal(name, "substr")) { } else if (zend_string_equals_literal(name, "substr")) {
if (Z_TYPE_P(args[0]) != IS_STRING if (Z_TYPE_P(args[0]) != IS_STRING
|| Z_TYPE_P(args[1]) != IS_LONG || Z_TYPE_P(args[1]) != IS_LONG) {
|| (CG(compiler_options) & ZEND_COMPILE_NO_BUILTIN_STRLEN)) {
return FAILURE; return FAILURE;
} }
/* pass */ /* pass */
@ -959,8 +957,7 @@ static inline int ct_eval_func_call(
} else if (zend_string_equals_literal(name, "substr")) { } else if (zend_string_equals_literal(name, "substr")) {
if (Z_TYPE_P(args[0]) != IS_STRING if (Z_TYPE_P(args[0]) != IS_STRING
|| Z_TYPE_P(args[1]) != IS_LONG || Z_TYPE_P(args[1]) != IS_LONG
|| Z_TYPE_P(args[2]) != IS_LONG || Z_TYPE_P(args[2]) != IS_LONG) {
|| (CG(compiler_options) & ZEND_COMPILE_NO_BUILTIN_STRLEN)) {
return FAILURE; return FAILURE;
} }
/* pass */ /* pass */

View file

@ -1,18 +0,0 @@
--TEST--
Bug #68644 strlen incorrect : mbstring + func_overload=2 + UTF-8 + Opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
mbstring.func_overload=2
mbstring.internal_encoding=UTF-8
--SKIPIF--
<?php if (!extension_loaded('Zend OPcache') || !extension_loaded("mbstring")) die("skip"); ?>
--FILE--
<?php
var_dump(strlen("中国, 北京"));
var_dump(mb_strlen("中国, 北京"));
?>
--EXPECT--
Deprecated: The mbstring.func_overload directive is deprecated in Unknown on line 0
int(6)
int(6)

View file

@ -1,20 +0,0 @@
--TEST--
Bug #75729: opcache segfault when installing Bitrix
--SKIPIF--
<?php if (!extension_loaded('mbstring')) die('skip mbstring not loaded'); ?>
--INI--
opcache.enable_cli=1
mbstring.func_overload=2
--FILE--
<?php
var_dump(strpos("foo", "o"));
var_dump(substr("foo", 1));
var_dump(substr("foo", 1, 1));
?>
--EXPECT--
Deprecated: The mbstring.func_overload directive is deprecated in Unknown on line 0
int(1)
string(2) "oo"
string(1) "o"

View file

@ -1672,17 +1672,6 @@ zend.assertions = 1
; http://php.net/mbstring.substitute-character ; http://php.net/mbstring.substitute-character
;mbstring.substitute_character = none ;mbstring.substitute_character = none
; overload(replace) single byte functions by mbstring functions.
; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(),
; etc. Possible values are 0,1,2,4 or combination of them.
; For example, 7 for overload everything.
; 0: No overload
; 1: Overload mail() function
; 2: Overload str*() functions
; 4: Overload ereg*() functions
; http://php.net/mbstring.func-overload
;mbstring.func_overload = 0
; enable strict encoding detection. ; enable strict encoding detection.
; Default: Off ; Default: Off
;mbstring.strict_detection = On ;mbstring.strict_detection = On

View file

@ -1672,17 +1672,6 @@ zend.assertions = -1
; http://php.net/mbstring.substitute-character ; http://php.net/mbstring.substitute-character
;mbstring.substitute_character = none ;mbstring.substitute_character = none
; overload(replace) single byte functions by mbstring functions.
; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(),
; etc. Possible values are 0,1,2,4 or combination of them.
; For example, 7 for overload everything.
; 0: No overload
; 1: Overload mail() function
; 2: Overload str*() functions
; 4: Overload ereg*() functions
; http://php.net/mbstring.func-overload
;mbstring.func_overload = 0
; enable strict encoding detection. ; enable strict encoding detection.
; Default: Off ; Default: Off
;mbstring.strict_detection = On ;mbstring.strict_detection = On