Calls to date_modify will mutate timelib_rel_time, causing date_date_set issues
| Bug #71525 | Calls to date_modify will mutate timelib_rel_time, causing date_date_set issues | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2016-02-04 21:00 UTC | Modified: | - |
|
||||||||||
| From: | seander@php.net | Assigned: | ||||||||||||
| Status: | Closed | Package: | Date/time related | |||||||||||
| PHP Version: | 7.0.3 | OS: | All | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2016-02-04 21:00 UTC] seander@php.net
Description:
------------
timelib_time->timelib_rel_time is mutated by date_modify, and because it is never zero'ed out it latters causes other date operations to fail (like date_date_set)
A reproduce is attached, and I will open a PR with a possible patch.
Test script:
---------------
<?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);
----
https://3v4l.org/PASOu
Expected result:
----------------
object(DateTime)#1 (3) {
["date"]=>
string(26) "2012-01-29 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
Actual result:
--------------
object(DateTime)#1 (3) {
["date"]=>
string(26) "2012-01-01 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2016-02-15 07:22 UTC] ab@php.net
-Status: Open +Status: Closed