123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- --TEST--
- Bug #53437 (Crash when using unserialized DatePeriod instance), variation 1
- --FILE--
- <?php
- $dp = new DatePeriod(new DateTime('2010-01-01 UTC'), new DateInterval('P1D'), 2);
- echo "Original:\r\n";
- foreach($dp as $dt) {
- echo $dt->format('Y-m-d H:i:s')."\r\n";
- }
- echo "\r\n";
- var_dump($dp);
- $ser = serialize($dp); // $ser is: O:10:"DatePeriod":0:{}
- // Create dangerous instance
- $dpu = unserialize($ser); // $dpu has invalid values???
- var_dump($dpu);
- echo "Unserialized:\r\n";
- foreach($dpu as $dt) {
- echo $dt->format('Y-m-d H:i:s')."\r\n";
- }
- ?>
- --EXPECTF--
- Original:
- 2010-01-01 00:00:00
- 2010-01-02 00:00:00
- 2010-01-03 00:00:00
- object(DatePeriod)#%d (6) {
- ["start"]=>
- object(DateTime)#%d (3) {
- ["date"]=>
- string(26) "2010-01-01 00:00:00.000000"
- ["timezone_type"]=>
- int(3)
- ["timezone"]=>
- string(3) "UTC"
- }
- ["current"]=>
- object(DateTime)#%d (3) {
- ["date"]=>
- string(26) "2010-01-04 00:00:00.000000"
- ["timezone_type"]=>
- int(3)
- ["timezone"]=>
- string(3) "UTC"
- }
- ["end"]=>
- NULL
- ["interval"]=>
- object(DateInterval)#%d (16) {
- ["y"]=>
- int(0)
- ["m"]=>
- int(0)
- ["d"]=>
- int(1)
- ["h"]=>
- int(0)
- ["i"]=>
- int(0)
- ["s"]=>
- int(0)
- ["f"]=>
- float(0)
- ["weekday"]=>
- int(0)
- ["weekday_behavior"]=>
- int(0)
- ["first_last_day_of"]=>
- int(0)
- ["invert"]=>
- int(0)
- ["days"]=>
- bool(false)
- ["special_type"]=>
- int(0)
- ["special_amount"]=>
- int(0)
- ["have_weekday_relative"]=>
- int(0)
- ["have_special_relative"]=>
- int(0)
- }
- ["recurrences"]=>
- int(3)
- ["include_start_date"]=>
- bool(true)
- }
- object(DatePeriod)#%d (6) {
- ["start"]=>
- object(DateTime)#%d (3) {
- ["date"]=>
- string(26) "2010-01-01 00:00:00.000000"
- ["timezone_type"]=>
- int(3)
- ["timezone"]=>
- string(3) "UTC"
- }
- ["current"]=>
- object(DateTime)#%d (3) {
- ["date"]=>
- string(26) "2010-01-04 00:00:00.000000"
- ["timezone_type"]=>
- int(3)
- ["timezone"]=>
- string(3) "UTC"
- }
- ["end"]=>
- NULL
- ["interval"]=>
- object(DateInterval)#%d (16) {
- ["y"]=>
- int(0)
- ["m"]=>
- int(0)
- ["d"]=>
- int(1)
- ["h"]=>
- int(0)
- ["i"]=>
- int(0)
- ["s"]=>
- int(0)
- ["f"]=>
- float(0)
- ["weekday"]=>
- int(0)
- ["weekday_behavior"]=>
- int(0)
- ["first_last_day_of"]=>
- int(0)
- ["invert"]=>
- int(0)
- ["days"]=>
- bool(false)
- ["special_type"]=>
- int(0)
- ["special_amount"]=>
- int(0)
- ["have_weekday_relative"]=>
- int(0)
- ["have_special_relative"]=>
- int(0)
- }
- ["recurrences"]=>
- int(3)
- ["include_start_date"]=>
- bool(true)
- }
- Unserialized:
- 2010-01-01 00:00:00
- 2010-01-02 00:00:00
- 2010-01-03 00:00:00
|