summaryrefslogtreecommitdiff
path: root/ext/date/php_date.c
diff options
context:
space:
mode:
authorDerick Rethans <github@derickrethans.nl>2019-02-28 13:51:10 +0000
committerDerick Rethans <github@derickrethans.nl>2019-02-28 13:51:10 +0000
commitd63a7aa6cfb549f3462be9f0a05bad80a59d20a0 (patch)
treea3aa0ec887a82487e118220d481bbb9ca8e548fa /ext/date/php_date.c
parent58d3dd466f2b0031e28bce4e27e4141685f9c9c4 (diff)
parent7d001aff03168260c9bfbd53a118f5de2566e264 (diff)
downloadphp-git-d63a7aa6cfb549f3462be9f0a05bad80a59d20a0.tar.gz
Merge branch 'PHP-7.2' into PHP-7.3
Diffstat (limited to 'ext/date/php_date.c')
-rw-r--r--ext/date/php_date.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 32530ef734..f290730737 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -4430,12 +4430,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);
}