From: Xinchen Hui Date: Mon, 16 Oct 2017 11:07:34 +0000 (+0800) Subject: Fixed bug #75378 ([REGRESSION] IntlDateFormatter::parse() does not change $position... X-Git-Tag: php-7.2.0RC5~50 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=863acd775389984e32cf7800258b68a815e12d41;p=php Fixed bug #75378 ([REGRESSION] IntlDateFormatter::parse() does not change $position argument) --- diff --git a/NEWS b/NEWS index 0fcb02c235..ced00b5946 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,10 @@ PHP NEWS - Fileinfo: . Upgrade bundled libmagic to 5.31. (Anatol) +- Intl: + . Fixed bug #75378 ([REGRESSION] IntlDateFormatter::parse() does not change + $position argument). (Laruence) + - JSON: . Fixed bug #68567 (JSON_PARTIAL_OUTPUT_ON_ERROR can result in JSON with null key). (Jakub Zelenka) diff --git a/ext/intl/dateformat/dateformat_parse.c b/ext/intl/dateformat/dateformat_parse.c index 0e2290ffa1..bdf9a1e32c 100644 --- a/ext/intl/dateformat/dateformat_parse.c +++ b/ext/intl/dateformat/dateformat_parse.c @@ -145,6 +145,7 @@ PHP_FUNCTION(datefmt_parse) DATE_FORMAT_METHOD_FETCH_OBJECT; if (z_parse_pos) { + ZVAL_DEREF(z_parse_pos); convert_to_long(z_parse_pos); if (ZEND_LONG_INT_OVFL(Z_LVAL_P(z_parse_pos))) { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); @@ -188,6 +189,7 @@ PHP_FUNCTION(datefmt_localtime) DATE_FORMAT_METHOD_FETCH_OBJECT; if (z_parse_pos) { + ZVAL_DEREF(z_parse_pos); convert_to_long(z_parse_pos); if (ZEND_LONG_INT_OVFL(Z_LVAL_P(z_parse_pos))) { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); diff --git a/ext/intl/tests/bug75378.phpt b/ext/intl/tests/bug75378.phpt new file mode 100644 index 0000000000..c79e7f68a2 --- /dev/null +++ b/ext/intl/tests/bug75378.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #75378 ([REGRESSION] IntlDateFormatter::parse() does not change $position argument) +--SKIPIF-- + +--FILE-- +parse("2017-10-12", $position); +var_dump($parsedDate, $position); +$localdate = $formatter->localtime("2017-10-12", $position1); +var_dump($localdate, $position1); +?> +--EXPECT-- +int(1507766400) +int(10) +array(9) { + ["tm_sec"]=> + int(0) + ["tm_min"]=> + int(0) + ["tm_hour"]=> + int(0) + ["tm_year"]=> + int(117) + ["tm_mday"]=> + int(12) + ["tm_wday"]=> + int(4) + ["tm_yday"]=> + int(285) + ["tm_mon"]=> + int(9) + ["tm_isdst"]=> + int(0) +} +int(10)