diff options
| author | Derick Rethans <github@derickrethans.nl> | 2019-02-28 13:50:35 +0000 |
|---|---|---|
| committer | Derick Rethans <github@derickrethans.nl> | 2019-02-28 13:50:35 +0000 |
| commit | a890c5beb8327b7fbb2f25347256ef0dc5809750 (patch) | |
| tree | d224f038c88ae56c65ae08322b88c9bc0edca463 /ext/date/php_date.c | |
| parent | 19a44ffb7be91344550fa700830b8e62a73031ba (diff) | |
| download | php-git-a890c5beb8327b7fbb2f25347256ef0dc5809750.tar.gz | |
Fixed bug #50020 (DateInterval:createDateFromString() silently fails)
Diffstat (limited to 'ext/date/php_date.c')
| -rw-r--r-- | ext/date/php_date.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index c8479b5164..5cc3f794cd 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -4435,12 +4435,21 @@ PHP_FUNCTION(date_interval_create_from_date_string) Z_PARAM_STR(time_str) ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); - php_date_instantiate(date_ce_interval, return_value); - time = timelib_strtotime(ZSTR_VAL(time_str), ZSTR_LEN(time_str), &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); + + if (err->error_count > 0) { + php_error_docref(NULL, E_WARNING, "Unknown or bad format (%s) at position %d (%c): %s", ZSTR_VAL(time_str), + err->error_messages[0].position, err->error_messages[0].character ? err->error_messages[0].character : ' ', err->error_messages[0].message); + RETVAL_FALSE; + goto cleanup; + } + + php_date_instantiate(date_ce_interval, return_value); diobj = Z_PHPINTERVAL_P(return_value); diobj->diff = timelib_rel_time_clone(&time->relative); diobj->initialized = 1; + +cleanup: timelib_time_dtor(time); timelib_error_container_dtor(err); } |
