Skip to content

Commit fdb0a96

Browse files
committed
use EG to guard
1 parent 563684a commit fdb0a96

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

ext/intl/common/common_date.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err)
205205
zval casted;
206206
ZVAL_UNDEF(&casted);
207207

208-
if (Z_OBJ_HT_P(z)->cast_object(Z_OBJ_P(z), &casted, _IS_NUMBER) == SUCCESS
209-
&& !EG(exception)) {
210-
if (Z_TYPE(casted) == IS_LONG) {
208+
if (Z_OBJ_HT_P(z)->cast_object(Z_OBJ_P(z), &casted, _IS_NUMBER) == SUCCESS) {
209+
if (EG(exception)) {
210+
} else if (Z_TYPE(casted) == IS_LONG) {
211211
rv = U_MILLIS_PER_SECOND * (double)Z_LVAL(casted);
212212
} else if (Z_TYPE(casted) == IS_DOUBLE) {
213213
rv = U_MILLIS_PER_SECOND * Z_DVAL(casted);
@@ -216,7 +216,7 @@ U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err)
216216
"invalid object type for date/time "
217217
"(IntlCalendar, DateTimeInterface, or numeric-castable object permitted)");
218218
}
219-
} else {
219+
} else if (!EG(exception)) {
220220
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR,
221221
"invalid object type for date/time "
222222
"(IntlCalendar, DateTimeInterface, or numeric-castable object permitted)");

ext/intl/tests/dateformat_formatObject_numeric_object.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ $fmt = new IntlDateFormatter('en_US', IntlDateFormatter::NONE, IntlDateFormatter
1313

1414
echo $fmt->format(new NumericCastableNoOperations(0)), "\n";
1515
echo datefmt_format($fmt, new NumericCastableNoOperations(0.5)), "\n";
16+
var_dump($fmt->format(new stdClass()));
17+
var_dump(intl_get_error_message());
1618

1719
?>
1820
--EXPECT--
1921
1970-01-01 00:00:00.000
2022
1970-01-01 00:00:00.500
23+
bool(false)
24+
string(146) "IntlDateFormatter::format(): invalid object type for date/time (IntlCalendar, DateTimeInterface, or numeric-castable object permitted): U_ILLEGAL_ARGUMENT_ERROR"

ext/intl/tests/dateformat_format_error.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ var_dump($v);
1919
var_dump(intl_get_error_message());
2020

2121
?>
22-
--EXPECTF--
22+
--EXPECT--
2323
bool(false)
24-
string(%d) "IntlDateFormatter::format(): invalid object type for date/time (IntlCalendar, DateTimeInterface, or numeric-castable object permitted): U_ILLEGAL_ARGUMENT_ERROR"
24+
string(146) "IntlDateFormatter::format(): invalid object type for date/time (IntlCalendar, DateTimeInterface, or numeric-castable object permitted): U_ILLEGAL_ARGUMENT_ERROR"
2525
bool(false)
26-
string(%d) "datefmt_format(): invalid object type for date/time (IntlCalendar, DateTimeInterface, or numeric-castable object permitted): U_ILLEGAL_ARGUMENT_ERROR"
26+
string(135) "datefmt_format(): invalid object type for date/time (IntlCalendar, DateTimeInterface, or numeric-castable object permitted): U_ILLEGAL_ARGUMENT_ERROR"

0 commit comments

Comments
 (0)