summaryrefslogtreecommitdiff
path: root/ext/intl
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2021-02-17 17:28:22 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2021-02-17 17:30:47 +0100
commit553a0c52b12d414c83130d845968fac5841236bf (patch)
treebe22e36bc6772bb523d30bb1153fbeba8b808839 /ext/intl
parentcbdd21a22d67b6d6ec44ca57a8493da611f6f68e (diff)
parent84b615284218736f4fe2450a5f43ef61f2a78901 (diff)
downloadphp-git-553a0c52b12d414c83130d845968fac5841236bf.tar.gz
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix #80763: msgfmt_format() does not accept DateTime references
Diffstat (limited to 'ext/intl')
-rw-r--r--ext/intl/common/common_date.cpp4
-rw-r--r--ext/intl/tests/bug80763.phpt16
2 files changed, 20 insertions, 0 deletions
diff --git a/ext/intl/common/common_date.cpp b/ext/intl/common/common_date.cpp
index d4767dc63b..5c1134aae7 100644
--- a/ext/intl/common/common_date.cpp
+++ b/ext/intl/common/common_date.cpp
@@ -173,6 +173,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);
@@ -225,6 +226,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 0000000000..bd5aeb45c6
--- /dev/null
+++ b/ext/intl/tests/bug80763.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #80763 (msgfmt_format() does not accept DateTime references)
+--SKIPIF--
+<?php
+if (!extension_loaded('intl')) die('skip intl extension not available');
+?>
+--FILE--
+<?php
+$today = new DateTime('2021-02-17 12:00:00');
+$formatter = new \MessageFormatter('en_US', 'Today is {today, date, full}.');
+$params = ['today' => $today];
+array_walk($params, fn() => 1);
+var_dump($formatter->format($params));
+?>
+--EXPECT--
+string(38) "Today is Wednesday, February 17, 2021."