Bug #71525 [NEW]: Calls to date_modify will mutate timelib_rel_time, causing date_date_set issues

From: Date: Thu, 04 Feb 2016 21:00:53 +0000
Subject: Bug #71525 [NEW]: Calls to date_modify will mutate timelib_rel_time, causing date_date_set issues
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199058@lists.php.net to get a copy of this message
From: seander Operating system: All PHP version: 7.0.3 Package: Date/time related Bug Type: Bug Bug description:Calls to date_modify will mutate timelib_rel_time, causing date_date_set issues 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" } -- Edit bug report at https://bugs.php.net/bug.php?id=71525&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71525&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71525&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71525&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71525&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71525&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71525&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71525&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71525&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71525&r=support Expected behavior: https://bugs.php.net/fix.php?id=71525&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71525&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71525&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71525&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71525&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71525&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71525&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71525&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71525&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71525&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71525&r=mysqlcfg

« previous php.bugs (#199058) next »