Skip to content

Commit 553a0c5

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix #80763: msgfmt_format() does not accept DateTime references
2 parents cbdd21a + 84b6152 commit 553a0c5

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

NEWS

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3-
?? ??? 2021, PHP 8.0.3
3+
?? ??? 2021, PHP 8.0.4
4+
5+
- Intl:
6+
. Fixed bug #80763 (msgfmt_format() does not accept DateTime references).
7+
(cmb)
8+
9+
18 Feb 2021, PHP 8.0.3
410

511
- Core:
612
. Fixed #80706 (mail(): Headers after Bcc headers may be ignored). (cmb)

ext/intl/common/common_date.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func)
173173
return ZEND_NAN;
174174
}
175175

176+
try_again:
176177
switch (Z_TYPE_P(z)) {
177178
case IS_STRING:
178179
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)
225226
efree(message);
226227
}
227228
break;
229+
case IS_REFERENCE:
230+
z = Z_REFVAL_P(z);
231+
goto try_again;
228232
default:
229233
spprintf(&message, 0, "%s: invalid PHP type for date", func);
230234
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR,

ext/intl/tests/bug80763.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #80763 (msgfmt_format() does not accept DateTime references)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('intl')) die('skip intl extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$today = new DateTime('2021-02-17 12:00:00');
10+
$formatter = new \MessageFormatter('en_US', 'Today is {today, date, full}.');
11+
$params = ['today' => $today];
12+
array_walk($params, fn() => 1);
13+
var_dump($formatter->format($params));
14+
?>
15+
--EXPECT--
16+
string(38) "Today is Wednesday, February 17, 2021."

0 commit comments

Comments
 (0)