com php-src: Backported fix for bug #71525: NEWS ext/date/php _date.c ext/date/tests/bug71525.phpt
| From: | Anatol Belski | Date: | Mon, 15 Feb 2016 14:14:23 +0000 |
| Subject: | com php-src: Backported fix for bug #71525: NEWS ext/date/php _date.c ext/date/tests/bug71525.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-91058@lists.php.net to get a copy of this message | ||
Commit: 633fb2d0e856243ed459cfe67a93c31352045c08
Author: Anatol Belski <ab@php.net> Mon, 15 Feb 2016 15:14:23 +0100
Parents: c11b23c46577e30e1e0a7c0abfb4c7ea735c34e1
Branches: PHP-5.6 PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=633fb2d0e856243ed459cfe67a93c31352045c08
Log:
Backported fix for bug #71525
Bugs:
https://bugs.php.net/71525
Changed paths:
M NEWS
M ext/date/php_date.c
A ext/date/tests/bug71525.phpt
Diff:
diff --git a/NEWS b/NEWS
index 5d641b4..eb43292 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 d5d06f6..e06ace7 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 0000000..d0c99e4
--- /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"
+}