From f2753298315b7035d2d59966081ab4854f924149 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 13 Mar 2025 20:46:52 +0000 Subject: [PATCH] ext/intl: Fix dateformat_format when the time is an array of references. --- ext/intl/dateformat/dateformat_format.c | 2 +- .../tests/dateformat_format_references.phpt | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 ext/intl/tests/dateformat_format_references.phpt diff --git a/ext/intl/dateformat/dateformat_format.c b/ext/intl/dateformat/dateformat_format.c index 9419469b4f609..928712934b15c 100644 --- a/ext/intl/dateformat/dateformat_format.c +++ b/ext/intl/dateformat/dateformat_format.c @@ -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); diff --git a/ext/intl/tests/dateformat_format_references.phpt b/ext/intl/tests/dateformat_format_references.phpt new file mode 100644 index 0000000000000..da1a52955f121 --- /dev/null +++ b/ext/intl/tests/dateformat_format_references.phpt @@ -0,0 +1,23 @@ +--TEST-- +Fix dateformat_format() with array argument with values as references. +--SKIPIF-- + +--FILE-- + &$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"