From 39fc4228456f8e73430822da1708c4d6a73ecaae Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 17 Feb 2021 14:05:28 +0100 Subject: [PATCH] Fix #80763: msgfmt_format() does not accept DateTime references `intl_zval_to_millis()` needs to cater to references. --- ext/intl/common/common_date.cpp | 4 ++++ ext/intl/tests/bug80763.phpt | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 ext/intl/tests/bug80763.phpt diff --git a/ext/intl/common/common_date.cpp b/ext/intl/common/common_date.cpp index b3e8a30f68905..207b81aa6f521 100644 --- a/ext/intl/common/common_date.cpp +++ b/ext/intl/common/common_date.cpp @@ -175,6 +175,7 @@ U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func) return ZEND_NAN; } +try_again: switch (Z_TYPE_P(z)) { case IS_STRING: type = is_numeric_string(Z_STRVAL_P(z), Z_STRLEN_P(z), &lv, &rv, 0); @@ -227,6 +228,9 @@ U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func) efree(message); } break; + case IS_REFERENCE: + z = Z_REFVAL_P(z); + goto try_again; default: spprintf(&message, 0, "%s: invalid PHP type for date", func); intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, diff --git a/ext/intl/tests/bug80763.phpt b/ext/intl/tests/bug80763.phpt new file mode 100644 index 0000000000000..bd5aeb45c6004 --- /dev/null +++ b/ext/intl/tests/bug80763.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #80763 (msgfmt_format() does not accept DateTime references) +--SKIPIF-- + +--FILE-- + $today]; +array_walk($params, fn() => 1); +var_dump($formatter->format($params)); +?> +--EXPECT-- +string(38) "Today is Wednesday, February 17, 2021."