Bug #78751 [NEW]: serialize() converts DateTimeImmutable to DateTime when serialising DatePeriod

From: Date: Fri, 25 Oct 2019 11:32:48 +0000
Subject: Bug #78751 [NEW]: serialize() converts DateTimeImmutable to DateTime when serialising DatePeriod
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223457@lists.php.net to get a copy of this message
From: michael dot heerklotz at web dot de Operating system: Ubuntu PHP version: 7.3.11 Package: Date/time related Bug Type: Bug Bug description:serialize() converts DateTimeImmutable to DateTime when serialising DatePeriod Description: ------------ When serialising (serialize()) a DatePeriod object which has been initialised with DateTimeImmutable instances, the DateTimeImmutable type gets lost, and is converted to DateTime Test script: --------------- <?php $oDay = new DateTimeImmutable('2019-10-25'); $oDateInterval = DateInterval::createFromDateString('1 day'); $oDays = new DatePeriod($oDay, $oDateInterval, $oDay->modify('+1 day')); print serialize($oDays); // Output: O:10:"DatePeriod":6:{s:5:"start";O:8:"DateTime": ... Expected result: ---------------- O:10:"DatePeriod":6:{s:5:"start";O:8:"DateTimeImmutable":3:{s:4:"date";s:26:"2019-10-25 00:00:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:10:"US/Pacific";}s:7:"current";N;s:3:"end";O:8:"DateTimeImmutable":3:{s:4:"date";s:26:"2019-10-26 00:00:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:10:"US/Pacific";}s:8:"interval";O:12:"DateInterval":16:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:1;s:1:"h";i:0;s:1:"i";i:0;s:1:"s";i:0;s:1:"f";d:0;s:7:"weekday";i:0;s:16:"weekday_behavior";i:0;s:17:"first_last_day_of";i:0;s:6:"invert";i:0;s:4:"days";b:0;s:12:"special_type";i:0;s:14:"special_amount";i:0;s:21:"have_weekday_relative";i:0;s:21:"have_special_relative";i:0;}s:11:"recurrences";i:1;s:18:"include_start_date";b:1;}2019-10-25 Actual result: -------------- O:10:"DatePeriod":6:{s:5:"start";O:8:"DateTime":3:{s:4:"date";s:26:"2019-10-25 00:00:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:10:"US/Pacific";}s:7:"current";N;s:3:"end";O:8:"DateTime":3:{s:4:"date";s:26:"2019-10-26 00:00:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:10:"US/Pacific";}s:8:"interval";O:12:"DateInterval":16:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:1;s:1:"h";i:0;s:1:"i";i:0;s:1:"s";i:0;s:1:"f";d:0;s:7:"weekday";i:0;s:16:"weekday_behavior";i:0;s:17:"first_last_day_of";i:0;s:6:"invert";i:0;s:4:"days";b:0;s:12:"special_type";i:0;s:14:"special_amount";i:0;s:21:"have_weekday_relative";i:0;s:21:"have_special_relative";i:0;}s:11:"recurrences";i:1;s:18:"include_start_date";b:1;}2019-10-25 -- Edit bug report at https://bugs.php.net/bug.php?id=78751&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=78751&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78751&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78751&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78751&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78751&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78751&r=support Expected behavior: https://bugs.php.net/fix.php?id=78751&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78751&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78751&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78751&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=78751&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=78751&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78751&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78751&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78751&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78751&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78751&r=mysqlcfg

« previous php.bugs (#223457) next »