File tree Expand file tree Collapse file tree 3 files changed +58
-3
lines changed Expand file tree Collapse file tree 3 files changed +58
-3
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ PHP NEWS
7
7
properties). (Laruence)
8
8
. Fixed misparsing of abstract unix domain socket names. (Sara)
9
9
10
+ - Date:
11
+ . Fixed bug #74639 (implement clone for DatePeriod and DateInterval).
12
+ (andrewnester)
13
+
10
14
- Mbstring:
11
15
. Add oniguruma upstream fix (CVE-2017-9224, CVE-2017-9226, CVE-2017-9227,
12
16
CVE-2017-9228, CVE-2017-9229) (Remi, Mamoru TASAKA)
Original file line number Diff line number Diff line change @@ -2397,8 +2397,11 @@ static zend_object *date_object_clone_interval(zval *this_ptr) /* {{{ */
2397
2397
php_interval_obj * new_obj = php_interval_obj_from_obj (date_object_new_interval_ex (old_obj -> std .ce , 0 ));
2398
2398
2399
2399
zend_objects_clone_members (& new_obj -> std , & old_obj -> std );
2400
+ new_obj -> initialized = old_obj -> initialized ;
2401
+ if (old_obj -> diff ) {
2402
+ new_obj -> diff = timelib_rel_time_clone (old_obj -> diff );
2403
+ }
2400
2404
2401
- /** FIX ME ADD CLONE STUFF **/
2402
2405
return & new_obj -> std ;
2403
2406
} /* }}} */
2404
2407
@@ -2481,8 +2484,23 @@ static zend_object *date_object_clone_period(zval *this_ptr) /* {{{ */
2481
2484
php_period_obj * new_obj = php_period_obj_from_obj (date_object_new_period_ex (old_obj -> std .ce , 0 ));
2482
2485
2483
2486
zend_objects_clone_members (& new_obj -> std , & old_obj -> std );
2484
-
2485
- /** FIX ME ADD CLONE STUFF **/
2487
+ new_obj -> initialized = old_obj -> initialized ;
2488
+ new_obj -> recurrences = old_obj -> recurrences ;
2489
+ new_obj -> include_start_date = old_obj -> include_start_date ;
2490
+ new_obj -> start_ce = old_obj -> start_ce ;
2491
+
2492
+ if (old_obj -> start ) {
2493
+ new_obj -> start = timelib_time_clone (old_obj -> start );
2494
+ }
2495
+ if (old_obj -> current ) {
2496
+ new_obj -> current = timelib_time_clone (old_obj -> current );
2497
+ }
2498
+ if (old_obj -> end ) {
2499
+ new_obj -> end = timelib_time_clone (old_obj -> end );
2500
+ }
2501
+ if (old_obj -> interval ) {
2502
+ new_obj -> interval = timelib_rel_time_clone (old_obj -> interval );
2503
+ }
2486
2504
return & new_obj -> std ;
2487
2505
} /* }}} */
2488
2506
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #74639 Cloning DatePeriod leads to segfault
3
+ --FILE--
4
+ <?php
5
+
6
+ $ start = new DateTime ('2017-05-22 09:00:00 ' );
7
+ $ end = new DateTime ('2017-08-24 18:00:00 ' );
8
+ $ interval = $ start ->diff ($ end );
9
+
10
+ $ period = new DatePeriod ($ start , $ interval , $ end );
11
+ $ clonedPeriod = clone $ period ;
12
+ $ clonedInterval = clone $ interval ;
13
+
14
+ if ($ period ->getStartDate () != $ clonedPeriod ->getStartDate ()) {
15
+ echo "failure \n" ;
16
+ }
17
+
18
+ if ($ period ->getEndDate () != $ clonedPeriod ->getEndDate ()) {
19
+ echo "failure \n" ;
20
+ }
21
+
22
+ if ($ period ->getDateInterval () != $ clonedPeriod ->getDateInterval ()) {
23
+ echo "failure \n" ;
24
+ }
25
+
26
+ if ($ interval ->format ('Y-m-d H:i:s ' ) != $ clonedInterval ->format ('Y-m-d H:i:s ' )) {
27
+ echo "failure \n" ;
28
+ }
29
+
30
+ echo 'success ' ;
31
+ ?>
32
+ --EXPECT--
33
+ success
You can’t perform that action at this time.
0 commit comments