Skip to content

Commit 331e56c

Browse files
committed
Remove mbstring.func_overload
Deprecated in PHP 7.2 as part of https://wiki.php.net/rfc/deprecations_php_7_2.
1 parent 920b4b2 commit 331e56c

16 files changed

+9
-379
lines changed

Zend/zend_compile.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3169,9 +3169,7 @@ int zend_compile_func_strlen(znode *result, zend_ast_list *args) /* {{{ */
31693169
{
31703170
znode arg_node;
31713171

3172-
if ((CG(compiler_options) & ZEND_COMPILE_NO_BUILTIN_STRLEN)
3173-
|| args->children != 1
3174-
) {
3172+
if (args->children != 1) {
31753173
return FAILURE;
31763174
}
31773175

Zend/zend_compile.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,9 +1035,6 @@ END_EXTERN_C()
10351035
/* disable constant substitution at compile-time */
10361036
#define ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION (1<<5)
10371037

1038-
/* disable usage of builtin instruction for strlen() */
1039-
#define ZEND_COMPILE_NO_BUILTIN_STRLEN (1<<6)
1040-
10411038
/* disable substitution of persistent constants at compile-time */
10421039
#define ZEND_COMPILE_NO_PERSISTENT_CONSTANT_SUBSTITUTION (1<<7)
10431040

ext/mbstring/mbstring.c

Lines changed: 4 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -174,25 +174,6 @@ static const php_mb_nls_ident_list php_mb_default_identify_list[] = {
174174

175175
/* }}} */
176176

177-
/* {{{ mb_overload_def mb_ovld[] */
178-
static const struct mb_overload_def mb_ovld[] = {
179-
{MB_OVERLOAD_MAIL, "mail", "mb_send_mail", "mb_orig_mail"},
180-
{MB_OVERLOAD_STRING, "strlen", "mb_strlen", "mb_orig_strlen"},
181-
{MB_OVERLOAD_STRING, "strpos", "mb_strpos", "mb_orig_strpos"},
182-
{MB_OVERLOAD_STRING, "strrpos", "mb_strrpos", "mb_orig_strrpos"},
183-
{MB_OVERLOAD_STRING, "stripos", "mb_stripos", "mb_orig_stripos"},
184-
{MB_OVERLOAD_STRING, "strripos", "mb_strripos", "mb_orig_strripos"},
185-
{MB_OVERLOAD_STRING, "strstr", "mb_strstr", "mb_orig_strstr"},
186-
{MB_OVERLOAD_STRING, "strrchr", "mb_strrchr", "mb_orig_strrchr"},
187-
{MB_OVERLOAD_STRING, "stristr", "mb_stristr", "mb_orig_stristr"},
188-
{MB_OVERLOAD_STRING, "substr", "mb_substr", "mb_orig_substr"},
189-
{MB_OVERLOAD_STRING, "strtolower", "mb_strtolower", "mb_orig_strtolower"},
190-
{MB_OVERLOAD_STRING, "strtoupper", "mb_strtoupper", "mb_orig_strtoupper"},
191-
{MB_OVERLOAD_STRING, "substr_count", "mb_substr_count", "mb_orig_substr_count"},
192-
{0, NULL, NULL, NULL}
193-
};
194-
/* }}} */
195-
196177
/* {{{ arginfo */
197178
ZEND_BEGIN_ARG_INFO_EX(arginfo_mb_language, 0, 0, 0)
198179
ZEND_ARG_INFO(0, language)
@@ -1486,8 +1467,6 @@ PHP_INI_BEGIN()
14861467
PHP_INI_ENTRY("mbstring.http_output", NULL, PHP_INI_ALL, OnUpdate_mbstring_http_output)
14871468
STD_PHP_INI_ENTRY("mbstring.internal_encoding", NULL, PHP_INI_ALL, OnUpdate_mbstring_internal_encoding, internal_encoding_name, zend_mbstring_globals, mbstring_globals)
14881469
PHP_INI_ENTRY("mbstring.substitute_character", NULL, PHP_INI_ALL, OnUpdate_mbstring_substitute_character)
1489-
STD_PHP_INI_ENTRY("mbstring.func_overload", "0",
1490-
PHP_INI_SYSTEM, OnUpdateLong, func_overload, zend_mbstring_globals, mbstring_globals)
14911470

14921471
STD_PHP_INI_BOOLEAN("mbstring.encoding_translation", "0",
14931472
PHP_INI_SYSTEM | PHP_INI_PERDIR,
@@ -1535,7 +1514,6 @@ ZEND_TSRMLS_CACHE_UPDATE();
15351514
mbstring_globals->current_filter_illegal_mode = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
15361515
mbstring_globals->current_filter_illegal_substchar = 0x3f; /* '?' */
15371516
mbstring_globals->illegalchars = 0;
1538-
mbstring_globals->func_overload = 0;
15391517
mbstring_globals->encoding_translation = 0;
15401518
mbstring_globals->strict_detection = 0;
15411519
mbstring_globals->outconv = NULL;
@@ -1584,10 +1562,6 @@ ZEND_TSRMLS_CACHE_UPDATE();
15841562
sapi_register_post_entries(mbstr_post_entries);
15851563
}
15861564

1587-
REGISTER_LONG_CONSTANT("MB_OVERLOAD_MAIL", MB_OVERLOAD_MAIL, CONST_CS | CONST_PERSISTENT);
1588-
REGISTER_LONG_CONSTANT("MB_OVERLOAD_STRING", MB_OVERLOAD_STRING, CONST_CS | CONST_PERSISTENT);
1589-
REGISTER_LONG_CONSTANT("MB_OVERLOAD_REGEX", MB_OVERLOAD_REGEX, CONST_CS | CONST_PERSISTENT);
1590-
15911565
REGISTER_LONG_CONSTANT("MB_CASE_UPPER", PHP_UNICODE_CASE_UPPER, CONST_CS | CONST_PERSISTENT);
15921566
REGISTER_LONG_CONSTANT("MB_CASE_LOWER", PHP_UNICODE_CASE_LOWER, CONST_CS | CONST_PERSISTENT);
15931567
REGISTER_LONG_CONSTANT("MB_CASE_TITLE", PHP_UNICODE_CASE_TITLE, CONST_CS | CONST_PERSISTENT);
@@ -1613,64 +1587,13 @@ ZEND_TSRMLS_CACHE_UPDATE();
16131587
php_mb_rfc1867_getword_conf,
16141588
php_mb_rfc1867_basename);
16151589

1616-
/* override original function (deprecated). */
1617-
if (MBSTRG(func_overload)){
1618-
zend_function *func, *orig;
1619-
const struct mb_overload_def *p;
1620-
zend_string *str;
1621-
1622-
p = &(mb_ovld[0]);
1623-
while (p->type > 0) {
1624-
if ((MBSTRG(func_overload) & p->type) == p->type &&
1625-
!zend_hash_str_exists(CG(function_table), p->save_func, strlen(p->save_func))
1626-
) {
1627-
func = zend_hash_str_find_ptr(CG(function_table), p->ovld_func, strlen(p->ovld_func));
1628-
1629-
if ((orig = zend_hash_str_find_ptr(CG(function_table), p->orig_func, strlen(p->orig_func))) == NULL) {
1630-
php_error_docref("ref.mbstring", E_WARNING, "mbstring couldn't find function %s.", p->orig_func);
1631-
return FAILURE;
1632-
} else {
1633-
ZEND_ASSERT(orig->type == ZEND_INTERNAL_FUNCTION);
1634-
str = zend_string_init_interned(p->save_func, strlen(p->save_func), 1);
1635-
zend_hash_add_mem(CG(function_table), str, orig, sizeof(zend_internal_function));
1636-
zend_string_release_ex(str, 1);
1637-
function_add_ref(orig);
1638-
1639-
str = zend_string_init_interned(p->orig_func, strlen(p->orig_func), 1);
1640-
zend_hash_update_mem(CG(function_table), str, func, sizeof(zend_internal_function));
1641-
zend_string_release_ex(str, 1);
1642-
function_add_ref(func);
1643-
}
1644-
}
1645-
p++;
1646-
}
1647-
}
1648-
16491590
return SUCCESS;
16501591
}
16511592
/* }}} */
16521593

16531594
/* {{{ PHP_MSHUTDOWN_FUNCTION(mbstring) */
16541595
PHP_MSHUTDOWN_FUNCTION(mbstring)
16551596
{
1656-
/* clear overloaded function. */
1657-
if (MBSTRG(func_overload)){
1658-
const struct mb_overload_def *p;
1659-
zend_function *orig;
1660-
1661-
p = &(mb_ovld[0]);
1662-
while (p->type > 0) {
1663-
if ((MBSTRG(func_overload) & p->type) == p->type &&
1664-
(orig = zend_hash_str_find_ptr(CG(function_table), p->save_func, strlen(p->save_func)))) {
1665-
1666-
zend_hash_str_update_mem(CG(function_table), p->orig_func, strlen(p->orig_func), orig, sizeof(zend_internal_function));
1667-
function_add_ref(orig);
1668-
zend_hash_str_del(CG(function_table), p->save_func, strlen(p->save_func));
1669-
}
1670-
p++;
1671-
}
1672-
}
1673-
16741597
UNREGISTER_INI_ENTRIES();
16751598

16761599
zend_multibyte_restore_functions();
@@ -1695,12 +1618,6 @@ PHP_RINIT_FUNCTION(mbstring)
16951618

16961619
php_mb_populate_current_detect_order_list();
16971620

1698-
/* override original function. */
1699-
if (MBSTRG(func_overload)){
1700-
zend_error(E_DEPRECATED, "The mbstring.func_overload directive is deprecated");
1701-
1702-
CG(compiler_options) |= ZEND_COMPILE_NO_BUILTIN_STRLEN;
1703-
}
17041621
#if HAVE_MBREGEX
17051622
PHP_RINIT(mb_regex) (INIT_FUNC_ARGS_PASSTHRU);
17061623
#endif
@@ -2782,11 +2699,6 @@ PHP_FUNCTION(mb_substr)
27822699
real_len = 0;
27832700
}
27842701

2785-
if (((MBSTRG(func_overload) & MB_OVERLOAD_STRING) == MB_OVERLOAD_STRING)
2786-
&& (real_from > mbfl_strlen(&string))) {
2787-
RETURN_FALSE;
2788-
}
2789-
27902702
ret = mbfl_substr(&string, &result, real_from, real_len);
27912703
if (NULL == ret) {
27922704
RETURN_FALSE;
@@ -4411,8 +4323,7 @@ PHP_FUNCTION(mb_get_info)
44114323
size_t typ_len;
44124324
size_t n;
44134325
char *name;
4414-
const struct mb_overload_def *over_func;
4415-
zval row1, row2;
4326+
zval row;
44164327
const mbfl_language *lang = mbfl_no2language(MBSTRG(language));
44174328
const mbfl_encoding **entry;
44184329

@@ -4434,20 +4345,6 @@ PHP_FUNCTION(mb_get_info)
44344345
if ((name = (char *)zend_ini_string("mbstring.http_output_conv_mimetypes", sizeof("mbstring.http_output_conv_mimetypes") - 1, 0)) != NULL) {
44354346
add_assoc_string(return_value, "http_output_conv_mimetypes", name);
44364347
}
4437-
add_assoc_long(return_value, "func_overload", MBSTRG(func_overload));
4438-
if (MBSTRG(func_overload)){
4439-
over_func = &(mb_ovld[0]);
4440-
array_init(&row1);
4441-
while (over_func->type > 0) {
4442-
if ((MBSTRG(func_overload) & over_func->type) == over_func->type ) {
4443-
add_assoc_string(&row1, over_func->orig_func, over_func->ovld_func);
4444-
}
4445-
over_func++;
4446-
}
4447-
add_assoc_zval(return_value, "func_overload_list", &row1);
4448-
} else {
4449-
add_assoc_string(return_value, "func_overload_list", "no overload");
4450-
}
44514348
if (lang != NULL) {
44524349
if ((name = (char *)mbfl_no_encoding2name(lang->mail_charset)) != NULL) {
44534350
add_assoc_string(return_value, "mail_charset", name);
@@ -4472,12 +4369,12 @@ PHP_FUNCTION(mb_get_info)
44724369
entry = MBSTRG(current_detect_order_list);
44734370
if (n > 0) {
44744371
size_t i;
4475-
array_init(&row2);
4372+
array_init(&row);
44764373
for (i = 0; i < n; i++) {
4477-
add_next_index_string(&row2, (*entry)->name);
4374+
add_next_index_string(&row, (*entry)->name);
44784375
entry++;
44794376
}
4480-
add_assoc_zval(return_value, "detect_order", &row2);
4377+
add_assoc_zval(return_value, "detect_order", &row);
44814378
}
44824379
if (MBSTRG(current_filter_illegal_mode) == MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE) {
44834380
add_assoc_string(return_value, "substitute_character", "none");
@@ -4509,21 +4406,6 @@ PHP_FUNCTION(mb_get_info)
45094406
if ((name = (char *)zend_ini_string("mbstring.http_output_conv_mimetypes", sizeof("mbstring.http_output_conv_mimetypes") - 1, 0)) != NULL) {
45104407
RETVAL_STRING(name);
45114408
}
4512-
} else if (!strcasecmp("func_overload", typ)) {
4513-
RETVAL_LONG(MBSTRG(func_overload));
4514-
} else if (!strcasecmp("func_overload_list", typ)) {
4515-
if (MBSTRG(func_overload)){
4516-
over_func = &(mb_ovld[0]);
4517-
array_init(return_value);
4518-
while (over_func->type > 0) {
4519-
if ((MBSTRG(func_overload) & over_func->type) == over_func->type ) {
4520-
add_assoc_string(return_value, over_func->orig_func, over_func->ovld_func);
4521-
}
4522-
over_func++;
4523-
}
4524-
} else {
4525-
RETVAL_STRING("no overload");
4526-
}
45274409
} else if (!strcasecmp("mail_charset", typ)) {
45284410
if (lang != NULL && (name = (char *)mbfl_no_encoding2name(lang->mail_charset)) != NULL) {
45294411
RETVAL_STRING(name);

ext/mbstring/mbstring.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ ZEND_BEGIN_MODULE_GLOBALS(mbstring)
155155
int filter_illegal_substchar;
156156
int current_filter_illegal_mode;
157157
int current_filter_illegal_substchar;
158-
zend_long func_overload;
159158
enum mbfl_no_language language;
160159
zend_bool encoding_translation;
161160
zend_bool strict_detection;
@@ -169,17 +168,6 @@ ZEND_BEGIN_MODULE_GLOBALS(mbstring)
169168
const mbfl_encoding *last_used_encoding;
170169
ZEND_END_MODULE_GLOBALS(mbstring)
171170

172-
#define MB_OVERLOAD_MAIL 1
173-
#define MB_OVERLOAD_STRING 2
174-
#define MB_OVERLOAD_REGEX 4
175-
176-
struct mb_overload_def {
177-
int type;
178-
char *orig_func;
179-
char *ovld_func;
180-
char *save_func;
181-
};
182-
183171
#define MBSTRG(v) ZEND_MODULE_GLOBALS_ACCESSOR(mbstring, v)
184172

185173
#if defined(ZTS) && defined(COMPILE_DL_MBSTRING)

ext/mbstring/tests/bug52931.phpt

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)