mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix GH-19070: setlocale($type, NULL) should not be deprecated
This restores the old behaviour. Closes GH-19071.
This commit is contained in:
2
NEWS
2
NEWS
@@ -8,6 +8,8 @@ PHP NEWS
|
|||||||
|
|
||||||
- Standard:
|
- Standard:
|
||||||
. Optimized pack(). (nielsdos, divinity76)
|
. Optimized pack(). (nielsdos, divinity76)
|
||||||
|
. Fixed bug GH-19070 (setlocale($type, NULL) should not be deprecated).
|
||||||
|
(nielsdos)
|
||||||
|
|
||||||
- URI:
|
- URI:
|
||||||
. Return the singleton UrlValidationErrorType instances from Uri\WhatWg\Url
|
. Return the singleton UrlValidationErrorType instances from Uri\WhatWg\Url
|
||||||
|
|||||||
@@ -2555,8 +2555,8 @@ function nl2br(string $string, bool $use_xhtml = true): string {}
|
|||||||
function strip_tags(string $string, array|string|null $allowed_tags = null): string {}
|
function strip_tags(string $string, array|string|null $allowed_tags = null): string {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array|string $locales
|
* @param array|string|null $locales
|
||||||
* @param string $rest
|
* @param string|null $rest
|
||||||
*/
|
*/
|
||||||
function setlocale(int $category, $locales, ...$rest): string|false {}
|
function setlocale(int $category, $locales, ...$rest): string|false {}
|
||||||
|
|
||||||
|
|||||||
2
ext/standard/basic_functions_arginfo.h
generated
2
ext/standard/basic_functions_arginfo.h
generated
@@ -1,5 +1,5 @@
|
|||||||
/* This is a generated file, edit the .stub.php file instead.
|
/* This is a generated file, edit the .stub.php file instead.
|
||||||
* Stub hash: f8c3745d39ed21f29f46b47f15b6fd1178e55dbb */
|
* Stub hash: b9958c8f2f643e072ba7c6ee33ad238ea8dd702e */
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
|
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
|
||||||
ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0)
|
ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0)
|
||||||
|
|||||||
@@ -4937,17 +4937,18 @@ PHP_FUNCTION(setlocale)
|
|||||||
zend_string **strings = do_alloca(sizeof(zend_string *) * num_args, use_heap);
|
zend_string **strings = do_alloca(sizeof(zend_string *) * num_args, use_heap);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < num_args; i++) {
|
for (uint32_t i = 0; i < num_args; i++) {
|
||||||
if (UNEXPECTED(Z_TYPE(args[i]) != IS_ARRAY && !zend_parse_arg_str(&args[i], &strings[i], false, i + 2))) {
|
if (UNEXPECTED(Z_TYPE(args[i]) != IS_ARRAY && !zend_parse_arg_str(&args[i], &strings[i], true, i + 2))) {
|
||||||
zend_wrong_parameter_type_error(i + 2, Z_EXPECTED_ARRAY_OR_STRING, &args[i]);
|
zend_wrong_parameter_type_error(i + 2, Z_EXPECTED_ARRAY_OR_STRING, &args[i]);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < num_args; i++) {
|
for (uint32_t i = 0; i < num_args; i++) {
|
||||||
|
zend_string *result;
|
||||||
if (Z_TYPE(args[i]) == IS_ARRAY) {
|
if (Z_TYPE(args[i]) == IS_ARRAY) {
|
||||||
zval *elem;
|
zval *elem;
|
||||||
ZEND_HASH_FOREACH_VAL(Z_ARRVAL(args[i]), elem) {
|
ZEND_HASH_FOREACH_VAL(Z_ARRVAL(args[i]), elem) {
|
||||||
zend_string *result = try_setlocale_zval(cat, elem);
|
result = try_setlocale_zval(cat, elem);
|
||||||
if (EG(exception)) {
|
if (EG(exception)) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -4956,15 +4957,18 @@ PHP_FUNCTION(setlocale)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
} ZEND_HASH_FOREACH_END();
|
} ZEND_HASH_FOREACH_END();
|
||||||
|
continue;
|
||||||
|
} else if (Z_ISNULL(args[i])) {
|
||||||
|
result = try_setlocale_str(cat, ZSTR_EMPTY_ALLOC());
|
||||||
} else {
|
} else {
|
||||||
zend_string *result = try_setlocale_str(cat, strings[i]);
|
result = try_setlocale_str(cat, strings[i]);
|
||||||
if (EG(exception)) {
|
}
|
||||||
goto out;
|
if (EG(exception)) {
|
||||||
}
|
goto out;
|
||||||
if (result) {
|
}
|
||||||
RETVAL_STR(result);
|
if (result) {
|
||||||
goto out;
|
RETVAL_STR(result);
|
||||||
}
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,5 @@ try {
|
|||||||
echo $e->getMessage(), "\n";
|
echo $e->getMessage(), "\n";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
Deprecated: setlocale(): Passing null to parameter #2 ($locales) of type string is deprecated in %s on line %d
|
|
||||||
no
|
no
|
||||||
|
|||||||
8
ext/standard/tests/strings/gh19070.phpt
Normal file
8
ext/standard/tests/strings/gh19070.phpt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
--TEST--
|
||||||
|
GH-19070 (setlocale($type, NULL) should not be deprecated)
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
var_dump(setlocale(LC_ALL, null));
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
string(%d) "%s"
|
||||||
Reference in New Issue
Block a user