Skip to content

Commit fdf45de

Browse files
committed
Remove deprecated behaviour of passing encoding as third parameter in mb_strrpos()
Merged GH-5011
1 parent 0a173ab commit fdf45de

File tree

4 files changed

+3
-121
lines changed

4 files changed

+3
-121
lines changed

UPGRADING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ PHP 8.0 UPGRADE NOTES
211211
restored with an explicit call to chr().
212212
. The $is_hex parameter, which was not used internally, has been removed from
213213
mb_decode_numericentity().
214+
. The legacy behaviour of passing the encoding as the third argument instead of an offset for the mb_strrpos
215+
function has been removed, provide an explicit 0 offset with the encoding as the fourth argument.
214216

215217
- PCRE:
216218
. When passing invalid escape sequences they are no longer interpreted as

ext/mbstring/mbstring.c

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,45 +2146,12 @@ PHP_FUNCTION(mb_strrpos)
21462146
{
21472147
mbfl_string haystack, needle;
21482148
zend_string *enc_name = NULL;
2149-
zval *zoffset = NULL;
21502149
zend_long offset = 0, n;
21512150

2152-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|zS", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &zoffset, &enc_name) == FAILURE) {
2151+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|lS", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &offset, &enc_name) == FAILURE) {
21532152
return;
21542153
}
21552154

2156-
if (zoffset) {
2157-
if (Z_TYPE_P(zoffset) == IS_STRING) {
2158-
switch (Z_STRVAL_P(zoffset)[0]) {
2159-
case '0':
2160-
case '1':
2161-
case '2':
2162-
case '3':
2163-
case '4':
2164-
case '5':
2165-
case '6':
2166-
case '7':
2167-
case '8':
2168-
case '9':
2169-
case ' ':
2170-
case '-':
2171-
case '.':
2172-
convert_to_long_ex(zoffset);
2173-
offset = Z_LVAL_P(zoffset);
2174-
break;
2175-
default :
2176-
enc_name = Z_STR_P(zoffset);
2177-
php_error_docref(NULL, E_DEPRECATED,
2178-
"Passing the encoding as third parameter is deprecated. "
2179-
"Use an explicit zero offset");
2180-
break;
2181-
}
2182-
} else {
2183-
convert_to_long_ex(zoffset);
2184-
offset = Z_LVAL_P(zoffset);
2185-
}
2186-
}
2187-
21882155
haystack.no_language = needle.no_language = MBSTRG(language);
21892156
haystack.encoding = needle.encoding = php_mb_get_encoding(enc_name);
21902157
if (!haystack.encoding) {

ext/mbstring/tests/mb_strrpos_encoding_3rd_param.phpt

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

ext/mbstring/tests/mb_strrpos_variation5.phpt

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

0 commit comments

Comments
 (0)