]> granicus.if.org Git - php/commitdiff
Backported fix for bug #71525
authorAnatol Belski <ab@php.net>
Mon, 15 Feb 2016 14:14:23 +0000 (15:14 +0100)
committerAnatol Belski <ab@php.net>
Mon, 15 Feb 2016 14:14:23 +0000 (15:14 +0100)
NEWS
ext/date/php_date.c
ext/date/tests/bug71525.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 5d641b4f1d7c594dec19f2504e14d529c355ac1c..eb4329215e0c19ee38a7f5b26b87f63c07253b60 100644 (file)
--- 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)
index d5d06f6b2778fdec1f54321d96726b163c16270d..e06ace7f8b811f1f5d378efc357a057d9168a8fc 100644 (file)
@@ -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 (file)
index 0000000..d0c99e4
--- /dev/null
@@ -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"
+}