ext/intl: Fix dateformat_format when the time is an array of references.

This commit is contained in:
David Carlier 2025-03-13 20:46:52 +00:00
parent 1c182674b0
commit f34859cb90
No known key found for this signature in database
GPG key ID: 8486F847B4B94EF1
3 changed files with 26 additions and 1 deletions

2
NEWS
View file

@ -18,6 +18,8 @@ PHP NEWS
- Intl:
. Fix locale_compose and locale_lookup to work with their array argument
with values as references. (David Carlier)
. Fix dateformat_format when the time is an array of references.
(David Carlier)
- Embed:
. Fixed bug GH-8533 (Unable to link dynamic libphp on Mac). (Kévin Dunglas)

View file

@ -64,7 +64,7 @@ static int32_t internal_get_arr_ele(IntlDateFormatter_object *dfo,
return result;
}
if ((ele_value = zend_hash_str_find(hash_arr, key_name, strlen(key_name))) != NULL) {
if ((ele_value = zend_hash_str_find_deref(hash_arr, key_name, strlen(key_name))) != NULL) {
if(Z_TYPE_P(ele_value) != IS_LONG) {
spprintf(&message, 0, "datefmt_format: parameter array contains "
"a non-integer element for key '%s'", key_name);

View file

@ -0,0 +1,23 @@
--TEST--
Fix dateformat_format() with array argument with values as references.
--SKIPIF--
<?php
if (PHP_OS_FAMILY === "Windows") die("skip currently unsupported on Windows");
?>
--FILE--
<?php
$a = 24;
$localtime_arr = array (
'tm_sec' => &$a ,
'tm_min' => 3,
'tm_hour' => 19,
'tm_mday' => 3,
'tm_mon' => 3,
'tm_year' => 105,
);
$fmt = datefmt_create('en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/New_York', IntlDateFormatter::GREGORIAN);
$formatted = datefmt_format($fmt , $localtime_arr);
var_dump($formatted);
?>
--EXPECTF--
string(%d) "Sunday, April 3, 2005 at 7:03:24%aPM Eastern Daylight Time"