Skip to content

Commit 633fb2d

Browse files
committed
Backported fix for bug #71525
1 parent c11b23c commit 633fb2d

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ PHP NEWS
1313
- Date:
1414
. Fixed bug #68078 (Datetime comparisons ignore microseconds). (Willem-Jan
1515
Zijderveld)
16+
. Fixed bug #71525 (Calls to date_modify will mutate timelib_rel_time,
17+
causing date_date_set issues). (Sean DuBois)
1618

1719
- Fileinfo:
1820
. Fixed bug #71434 (finfo throws notice for specific python file). (Laruence)

ext/date/php_date.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,6 +3143,7 @@ static int php_date_modify(zval *object, char *modify, int modify_len TSRMLS_DC)
31433143
timelib_update_ts(dateobj->time, NULL);
31443144
timelib_update_from_sse(dateobj->time);
31453145
dateobj->time->have_relative = 0;
3146+
memset(&dateobj->time->relative, 0, sizeof(dateobj->time->relative));
31463147

31473148
return 1;
31483149
}

ext/date/tests/bug71525.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #71525 (Calls to date_modify will mutate timelib_rel_time, causing date_date_set issues)
3+
--INI--
4+
date.timezone=UTC
5+
--FILE--
6+
<?php
7+
$date = new DateTime('2011-12-25 00:00:00');
8+
$date->modify('first day of next month');
9+
$date->setDate('2012', '1', '29');
10+
var_dump($date);
11+
12+
--EXPECTF--
13+
object(DateTime)#%d (3) {
14+
["date"]=>
15+
string(26) "2012-01-29 00:00:00.000000"
16+
["timezone_type"]=>
17+
int(3)
18+
["timezone"]=>
19+
string(3) "UTC"
20+
}

0 commit comments

Comments
 (0)