bug53437.phpt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. --TEST--
  2. Bug #53437 (Crash when using unserialized DatePeriod instance), variation 1
  3. --FILE--
  4. <?php
  5. $dp = new DatePeriod(new DateTime('2010-01-01 UTC'), new DateInterval('P1D'), 2);
  6. echo "Original:\r\n";
  7. foreach($dp as $dt) {
  8. echo $dt->format('Y-m-d H:i:s')."\r\n";
  9. }
  10. echo "\r\n";
  11. var_dump($dp);
  12. $ser = serialize($dp); // $ser is: O:10:"DatePeriod":0:{}
  13. // Create dangerous instance
  14. $dpu = unserialize($ser); // $dpu has invalid values???
  15. var_dump($dpu);
  16. echo "Unserialized:\r\n";
  17. foreach($dpu as $dt) {
  18. echo $dt->format('Y-m-d H:i:s')."\r\n";
  19. }
  20. ?>
  21. --EXPECTF--
  22. Original:
  23. 2010-01-01 00:00:00
  24. 2010-01-02 00:00:00
  25. 2010-01-03 00:00:00
  26. object(DatePeriod)#%d (6) {
  27. ["start"]=>
  28. object(DateTime)#%d (3) {
  29. ["date"]=>
  30. string(26) "2010-01-01 00:00:00.000000"
  31. ["timezone_type"]=>
  32. int(3)
  33. ["timezone"]=>
  34. string(3) "UTC"
  35. }
  36. ["current"]=>
  37. object(DateTime)#%d (3) {
  38. ["date"]=>
  39. string(26) "2010-01-04 00:00:00.000000"
  40. ["timezone_type"]=>
  41. int(3)
  42. ["timezone"]=>
  43. string(3) "UTC"
  44. }
  45. ["end"]=>
  46. NULL
  47. ["interval"]=>
  48. object(DateInterval)#%d (16) {
  49. ["y"]=>
  50. int(0)
  51. ["m"]=>
  52. int(0)
  53. ["d"]=>
  54. int(1)
  55. ["h"]=>
  56. int(0)
  57. ["i"]=>
  58. int(0)
  59. ["s"]=>
  60. int(0)
  61. ["f"]=>
  62. float(0)
  63. ["weekday"]=>
  64. int(0)
  65. ["weekday_behavior"]=>
  66. int(0)
  67. ["first_last_day_of"]=>
  68. int(0)
  69. ["invert"]=>
  70. int(0)
  71. ["days"]=>
  72. bool(false)
  73. ["special_type"]=>
  74. int(0)
  75. ["special_amount"]=>
  76. int(0)
  77. ["have_weekday_relative"]=>
  78. int(0)
  79. ["have_special_relative"]=>
  80. int(0)
  81. }
  82. ["recurrences"]=>
  83. int(3)
  84. ["include_start_date"]=>
  85. bool(true)
  86. }
  87. object(DatePeriod)#%d (6) {
  88. ["start"]=>
  89. object(DateTime)#%d (3) {
  90. ["date"]=>
  91. string(26) "2010-01-01 00:00:00.000000"
  92. ["timezone_type"]=>
  93. int(3)
  94. ["timezone"]=>
  95. string(3) "UTC"
  96. }
  97. ["current"]=>
  98. object(DateTime)#%d (3) {
  99. ["date"]=>
  100. string(26) "2010-01-04 00:00:00.000000"
  101. ["timezone_type"]=>
  102. int(3)
  103. ["timezone"]=>
  104. string(3) "UTC"
  105. }
  106. ["end"]=>
  107. NULL
  108. ["interval"]=>
  109. object(DateInterval)#%d (16) {
  110. ["y"]=>
  111. int(0)
  112. ["m"]=>
  113. int(0)
  114. ["d"]=>
  115. int(1)
  116. ["h"]=>
  117. int(0)
  118. ["i"]=>
  119. int(0)
  120. ["s"]=>
  121. int(0)
  122. ["f"]=>
  123. float(0)
  124. ["weekday"]=>
  125. int(0)
  126. ["weekday_behavior"]=>
  127. int(0)
  128. ["first_last_day_of"]=>
  129. int(0)
  130. ["invert"]=>
  131. int(0)
  132. ["days"]=>
  133. bool(false)
  134. ["special_type"]=>
  135. int(0)
  136. ["special_amount"]=>
  137. int(0)
  138. ["have_weekday_relative"]=>
  139. int(0)
  140. ["have_special_relative"]=>
  141. int(0)
  142. }
  143. ["recurrences"]=>
  144. int(3)
  145. ["include_start_date"]=>
  146. bool(true)
  147. }
  148. Unserialized:
  149. 2010-01-01 00:00:00
  150. 2010-01-02 00:00:00
  151. 2010-01-03 00:00:00