diff options
author | Derick Rethans <github@derickrethans.nl> | 2019-02-28 13:52:46 +0000 |
---|---|---|
committer | Derick Rethans <github@derickrethans.nl> | 2019-02-28 13:52:46 +0000 |
commit | 29f15a1333ad16b25b6da83d1cd4c7a43e984ca8 (patch) | |
tree | 6fd9ab328f9258810d0dcd8f99e0c58acb1dffc4 /ext/date/php_date.c | |
parent | 0c1470f9b7115f224c4aa01562e777e98ee52580 (diff) | |
parent | 9624e87a8fb4a3ae99bd6ed2cda6bd953ce3d98c (diff) | |
download | php-git-29f15a1333ad16b25b6da83d1cd4c7a43e984ca8.tar.gz |
Merge branch 'PHP-7.4'
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 011454d163..85376069e6 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -4375,12 +4375,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); } |