com php-src: Fixed bug #75378 ([REGRESSION] IntlDateFormatter::parse() does not change $position argument): NEWS ext/intl/dateformat/datefo
rmat_parse.c ext/intl/tests/bug75378.phpt

From: Date: Mon, 16 Oct 2017 11:07:34 +0000
Subject: com php-src: Fixed bug #75378 ([REGRESSION] IntlDateFormatter::parse() does not change $position argument): NEWS ext/intl/dateformat/datefo
rmat_parse.c ext/intl/tests/bug75378.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-99760@lists.php.net to get a copy of this message
Commit: 863acd775389984e32cf7800258b68a815e12d41 Author: Xinchen Hui <laruence@gmail.com> Mon, 16 Oct 2017 19:07:34 +0800 Parents: 8e147f12b9b0cd9b2488411a2933affa99a13423 Branches: PHP-7.2 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=863acd775389984e32cf7800258b68a815e12d41 Log: Fixed bug #75378 ([REGRESSION] IntlDateFormatter::parse() does not change $position argument) Bugs: https://bugs.php.net/75378 Changed paths: M NEWS M ext/intl/dateformat/dateformat_parse.c A ext/intl/tests/bug75378.phpt Diff: diff --git a/NEWS b/NEWS index 0fcb02c..ced00b5 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 0e2290f..bdf9a1e 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 0000000..c79e7f6 --- /dev/null +++ b/ext/intl/tests/bug75378.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #75378 ([REGRESSION] IntlDateFormatter::parse() does not change $position argument) +--SKIPIF-- +<?php +if (!extension_loaded('intl')) die('skip this test requires ext/intl'); +?> +--FILE-- +<?php + +$formatter = new IntlDateFormatter("en-GB", IntlDateFormatter::NONE, IntlDateFormatter::NONE, 'UTC', null, 'yyyy-MM-dd'); +$position = 0; +$parsedDate = $formatter->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)

« previous php.cvs (#99760) next »