summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2016-02-15 15:14:23 +0100
committerAnatol Belski <ab@php.net>2016-02-15 15:14:23 +0100
commit633fb2d0e856243ed459cfe67a93c31352045c08 (patch)
treed456f5f76e55f7ac0b4e62bb0132023f6e4ca9bf
parentc11b23c46577e30e1e0a7c0abfb4c7ea735c34e1 (diff)
downloadphp-git-633fb2d0e856243ed459cfe67a93c31352045c08.tar.gz
Backported fix for bug #71525
-rw-r--r--NEWS2
-rw-r--r--ext/date/php_date.c1
-rw-r--r--ext/date/tests/bug71525.phpt20
3 files changed, 23 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 5d641b4f1d..eb4329215e 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,8 @@ PHP NEWS
- Date:
. Fixed bug #68078 (Datetime comparisons ignore microseconds). (Willem-Jan
Zijderveld)
+ . Fixed bug #71525 (Calls to date_modify will mutate timelib_rel_time,
+ causing date_date_set issues). (Sean DuBois)
- Fileinfo:
. Fixed bug #71434 (finfo throws notice for specific python file). (Laruence)
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index d5d06f6b27..e06ace7f8b 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -3143,6 +3143,7 @@ static int php_date_modify(zval *object, char *modify, int modify_len TSRMLS_DC)
timelib_update_ts(dateobj->time, NULL);
timelib_update_from_sse(dateobj->time);
dateobj->time->have_relative = 0;
+ memset(&dateobj->time->relative, 0, sizeof(dateobj->time->relative));
return 1;
}
diff --git a/ext/date/tests/bug71525.phpt b/ext/date/tests/bug71525.phpt
new file mode 100644
index 0000000000..d0c99e4f84
--- /dev/null
+++ b/ext/date/tests/bug71525.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #71525 (Calls to date_modify will mutate timelib_rel_time, causing date_date_set issues)
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+$date = new DateTime('2011-12-25 00:00:00');
+$date->modify('first day of next month');
+$date->setDate('2012', '1', '29');
+var_dump($date);
+
+--EXPECTF--
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(26) "2012-01-29 00:00:00.000000"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(3) "UTC"
+}