summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2017-10-16 19:07:34 +0800
committerXinchen Hui <laruence@gmail.com>2017-10-16 19:07:34 +0800
commit863acd775389984e32cf7800258b68a815e12d41 (patch)
treee5c7c05ddcf76c57081a6fd4cd4edd76132475c8
parent8e147f12b9b0cd9b2488411a2933affa99a13423 (diff)
downloadphp-git-863acd775389984e32cf7800258b68a815e12d41.tar.gz
Fixed bug #75378 ([REGRESSION] IntlDateFormatter::parse() does not change $position argument)
-rw-r--r--NEWS4
-rw-r--r--ext/intl/dateformat/dateformat_parse.c2
-rw-r--r--ext/intl/tests/bug75378.phpt40
3 files changed, 46 insertions, 0 deletions
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--
+<?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)