mirror of
https://github.com/php/php-src.git
synced 2024-11-23 01:44:06 +08:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-14732: date_sun_info() fails for non-finite values
This commit is contained in:
commit
7c37c25ef2
@ -5487,6 +5487,10 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, bool calc_s
|
||||
}
|
||||
altitude = 90 - zenith;
|
||||
|
||||
if (!zend_finite(latitude) || !zend_finite(longitude)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* Initialize time struct */
|
||||
tzi = get_timezone_info();
|
||||
if (!tzi) {
|
||||
@ -5564,6 +5568,15 @@ PHP_FUNCTION(date_sun_info)
|
||||
Z_PARAM_DOUBLE(longitude)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (!zend_finite(latitude)) {
|
||||
zend_argument_value_error(2, "must be finite");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
if (!zend_finite(longitude)) {
|
||||
zend_argument_value_error(3, "must be finite");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
/* Initialize time struct */
|
||||
tzi = get_timezone_info();
|
||||
if (!tzi) {
|
||||
|
42
ext/date/tests/gh14732.phpt
Normal file
42
ext/date/tests/gh14732.phpt
Normal file
@ -0,0 +1,42 @@
|
||||
--TEST--
|
||||
GH-14732 (date_sun_info() fails for non-finite values)
|
||||
--FILE--
|
||||
<?php
|
||||
try {
|
||||
date_sun_info(1, NAN, 1);
|
||||
} catch (ValueError $ex) {
|
||||
echo $ex->getMessage(), "\n";
|
||||
}
|
||||
try {
|
||||
date_sun_info(1, -INF, 1);
|
||||
} catch (ValueError $ex) {
|
||||
echo $ex->getMessage(), "\n";
|
||||
}
|
||||
try {
|
||||
date_sun_info(1, 1, NAN);
|
||||
} catch (ValueError $ex) {
|
||||
echo $ex->getMessage(), "\n";
|
||||
}
|
||||
try {
|
||||
date_sun_info(1, 1, INF);
|
||||
} catch (ValueError $ex) {
|
||||
echo $ex->getMessage(), "\n";
|
||||
}
|
||||
var_dump(date_sunset(1, SUNFUNCS_RET_STRING, NAN, 1));
|
||||
var_dump(date_sunrise(1, SUNFUNCS_RET_STRING, 1, NAN));
|
||||
?>
|
||||
--EXPECTF--
|
||||
date_sun_info(): Argument #2 ($latitude) must be finite
|
||||
date_sun_info(): Argument #2 ($latitude) must be finite
|
||||
date_sun_info(): Argument #3 ($longitude) must be finite
|
||||
date_sun_info(): Argument #3 ($longitude) must be finite
|
||||
|
||||
Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d
|
||||
|
||||
Deprecated: Function date_sunset() is deprecated since 8.1, use date_sun_info() instead in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d
|
||||
|
||||
Deprecated: Function date_sunrise() is deprecated since 8.1, use date_sun_info() instead in %s on line %d
|
||||
bool(false)
|
Loading…
Reference in New Issue
Block a user