xref: /PHP-5.4/ext/date/tests/bug52113.phpt (revision fdb2709d)
1--TEST--
2Bug #52113 (Seg fault while creating (by unserialization) DatePeriod)
3--INI--
4date.timezone=UTC
5--FILE--
6<?php
7$start = new DateTime('2003-01-02 08:00:00');
8$end = new DateTime('2003-01-02 12:00:00');
9$diff = $start->diff($end);
10$p = new DatePeriod($start, $diff, 2);
11$diff_s = serialize($diff);
12var_dump($diff, $diff_s);
13var_export($diff);
14
15$diff_un = unserialize($diff_s);
16$p = new DatePeriod($start, $diff_un, 2);
17var_dump($diff_un, $p);
18
19$unser = DateInterval::__set_state(array(
20   'y' => 7,
21   'm' => 6,
22   'd' => 5,
23   'h' => 4,
24   'i' => 3,
25   's' => 2,
26   'invert' => 1,
27   'days' => 2400,
28));
29
30$p = new DatePeriod($start, $diff_un, 2);
31var_dump($unser, $p);
32
33?>
34--EXPECT--
35object(DateInterval)#3 (15) {
36  ["y"]=>
37  int(0)
38  ["m"]=>
39  int(0)
40  ["d"]=>
41  int(0)
42  ["h"]=>
43  int(4)
44  ["i"]=>
45  int(0)
46  ["s"]=>
47  int(0)
48  ["weekday"]=>
49  int(0)
50  ["weekday_behavior"]=>
51  int(0)
52  ["first_last_day_of"]=>
53  int(0)
54  ["invert"]=>
55  int(0)
56  ["days"]=>
57  int(0)
58  ["special_type"]=>
59  int(0)
60  ["special_amount"]=>
61  int(0)
62  ["have_weekday_relative"]=>
63  int(0)
64  ["have_special_relative"]=>
65  int(0)
66}
67string(320) "O:12:"DateInterval":15:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:0;s:1:"h";i:4;s:1:"i";i:0;s:1:"s";i: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";i: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;}"
68DateInterval::__set_state(array(
69   'y' => 0,
70   'm' => 0,
71   'd' => 0,
72   'h' => 4,
73   'i' => 0,
74   's' => 0,
75   'weekday' => 0,
76   'weekday_behavior' => 0,
77   'first_last_day_of' => 0,
78   'invert' => 0,
79   'days' => 0,
80   'special_type' => 0,
81   'special_amount' => 0,
82   'have_weekday_relative' => 0,
83   'have_special_relative' => 0,
84))object(DateInterval)#5 (15) {
85  ["y"]=>
86  int(0)
87  ["m"]=>
88  int(0)
89  ["d"]=>
90  int(0)
91  ["h"]=>
92  int(4)
93  ["i"]=>
94  int(0)
95  ["s"]=>
96  int(0)
97  ["weekday"]=>
98  int(0)
99  ["weekday_behavior"]=>
100  int(0)
101  ["first_last_day_of"]=>
102  int(0)
103  ["invert"]=>
104  int(0)
105  ["days"]=>
106  int(0)
107  ["special_type"]=>
108  int(0)
109  ["special_amount"]=>
110  int(0)
111  ["have_weekday_relative"]=>
112  int(0)
113  ["have_special_relative"]=>
114  int(0)
115}
116object(DatePeriod)#6 (6) {
117  ["start"]=>
118  object(DateTime)#4 (3) {
119    ["date"]=>
120    string(26) "2003-01-02 08:00:00.000000"
121    ["timezone_type"]=>
122    int(3)
123    ["timezone"]=>
124    string(3) "UTC"
125  }
126  ["current"]=>
127  NULL
128  ["end"]=>
129  NULL
130  ["interval"]=>
131  object(DateInterval)#7 (15) {
132    ["y"]=>
133    int(0)
134    ["m"]=>
135    int(0)
136    ["d"]=>
137    int(0)
138    ["h"]=>
139    int(4)
140    ["i"]=>
141    int(0)
142    ["s"]=>
143    int(0)
144    ["weekday"]=>
145    int(0)
146    ["weekday_behavior"]=>
147    int(0)
148    ["first_last_day_of"]=>
149    int(0)
150    ["invert"]=>
151    int(0)
152    ["days"]=>
153    int(0)
154    ["special_type"]=>
155    int(0)
156    ["special_amount"]=>
157    int(0)
158    ["have_weekday_relative"]=>
159    int(0)
160    ["have_special_relative"]=>
161    int(0)
162  }
163  ["recurrences"]=>
164  int(3)
165  ["include_start_date"]=>
166  bool(true)
167}
168object(DateInterval)#8 (15) {
169  ["y"]=>
170  int(7)
171  ["m"]=>
172  int(6)
173  ["d"]=>
174  int(5)
175  ["h"]=>
176  int(4)
177  ["i"]=>
178  int(3)
179  ["s"]=>
180  int(2)
181  ["weekday"]=>
182  int(-1)
183  ["weekday_behavior"]=>
184  int(-1)
185  ["first_last_day_of"]=>
186  int(-1)
187  ["invert"]=>
188  int(1)
189  ["days"]=>
190  int(2400)
191  ["special_type"]=>
192  int(0)
193  ["special_amount"]=>
194  int(-1)
195  ["have_weekday_relative"]=>
196  int(0)
197  ["have_special_relative"]=>
198  int(0)
199}
200object(DatePeriod)#9 (6) {
201  ["start"]=>
202  object(DateTime)#6 (3) {
203    ["date"]=>
204    string(26) "2003-01-02 08:00:00.000000"
205    ["timezone_type"]=>
206    int(3)
207    ["timezone"]=>
208    string(3) "UTC"
209  }
210  ["current"]=>
211  NULL
212  ["end"]=>
213  NULL
214  ["interval"]=>
215  object(DateInterval)#7 (15) {
216    ["y"]=>
217    int(0)
218    ["m"]=>
219    int(0)
220    ["d"]=>
221    int(0)
222    ["h"]=>
223    int(4)
224    ["i"]=>
225    int(0)
226    ["s"]=>
227    int(0)
228    ["weekday"]=>
229    int(0)
230    ["weekday_behavior"]=>
231    int(0)
232    ["first_last_day_of"]=>
233    int(0)
234    ["invert"]=>
235    int(0)
236    ["days"]=>
237    int(0)
238    ["special_type"]=>
239    int(0)
240    ["special_amount"]=>
241    int(0)
242    ["have_weekday_relative"]=>
243    int(0)
244    ["have_special_relative"]=>
245    int(0)
246  }
247  ["recurrences"]=>
248  int(3)
249  ["include_start_date"]=>
250  bool(true)
251}
252