Skip to content

Commit 197568d

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #70153 \DateInterval incorrectly unserialized
2 parents a6a2d16 + c7c7ab5 commit 197568d

File tree

6 files changed

+34
-4
lines changed

6 files changed

+34
-4
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 7.4.0RC5
44

5+
- Date:
6+
. Fixed bug #70153 (\DateInterval incorrectly unserialized). (Maksim Iakunin)
57

68
17 Oct 2019, PHP 7.4.0RC4
79

ext/date/php_date.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -4396,6 +4396,20 @@ static int php_date_interval_initialize_from_hash(zval **return_value, php_inter
43964396
} \
43974397
} while (0);
43984398

4399+
#define PHP_DATE_INTERVAL_READ_PROPERTY_DAYS(member) \
4400+
do { \
4401+
zval *z_arg = zend_hash_str_find(myht, "days", sizeof("days") - 1); \
4402+
if (z_arg && Z_TYPE_P(z_arg) == IS_FALSE) { \
4403+
(*intobj)->diff->member = -99999; \
4404+
} else if (z_arg && Z_TYPE_P(z_arg) <= IS_STRING) { \
4405+
zend_string *str = zval_get_string(z_arg); \
4406+
DATE_A64I((*intobj)->diff->member, ZSTR_VAL(str)); \
4407+
zend_string_release(str); \
4408+
} else { \
4409+
(*intobj)->diff->member = -1LL; \
4410+
} \
4411+
} while (0);
4412+
43994413
#define PHP_DATE_INTERVAL_READ_PROPERTY_DOUBLE(element, member, def) \
44004414
do { \
44014415
zval *z_arg = zend_hash_str_find(myht, element, sizeof(element) - 1); \
@@ -4424,7 +4438,7 @@ static int php_date_interval_initialize_from_hash(zval **return_value, php_inter
44244438
PHP_DATE_INTERVAL_READ_PROPERTY("weekday_behavior", weekday_behavior, int, -1)
44254439
PHP_DATE_INTERVAL_READ_PROPERTY("first_last_day_of", first_last_day_of, int, -1)
44264440
PHP_DATE_INTERVAL_READ_PROPERTY("invert", invert, int, 0);
4427-
PHP_DATE_INTERVAL_READ_PROPERTY_I64("days", days);
4441+
PHP_DATE_INTERVAL_READ_PROPERTY_DAYS(days);
44284442
PHP_DATE_INTERVAL_READ_PROPERTY("special_type", special.type, unsigned int, 0);
44294443
PHP_DATE_INTERVAL_READ_PROPERTY_I64("special_amount", special.amount);
44304444
PHP_DATE_INTERVAL_READ_PROPERTY("have_weekday_relative", have_weekday_relative, unsigned int, 0);

ext/date/tests/bug48678.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ DateInterval Object
3939
[weekday_behavior] => 0
4040
[first_last_day_of] => 0
4141
[invert] => 0
42-
[days] => 0
42+
[days] =>
4343
[special_type] => 0
4444
[special_amount] => 0
4545
[have_weekday_relative] => 0

ext/date/tests/bug53437.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ object(DatePeriod)#%d (6) {
136136
["invert"]=>
137137
int(0)
138138
["days"]=>
139-
int(0)
139+
bool(false)
140140
["special_type"]=>
141141
int(0)
142142
["special_amount"]=>

ext/date/tests/bug53437_var2.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ object(DateInterval)#2 (16) {
7171
["invert"]=>
7272
int(0)
7373
["days"]=>
74-
int(0)
74+
bool(false)
7575
["special_type"]=>
7676
int(0)
7777
["special_amount"]=>

ext/date/tests/bug70153.phpt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #70153 (\DateInterval incorrectly unserialized)
3+
--FILE--
4+
<?php
5+
$i1 = \DateInterval::createFromDateString('+1 month');
6+
$i2 = unserialize(serialize($i1));
7+
var_dump($i1->days, $i2->days);
8+
var_dump($i2->special_amount, $i2->special_amount);
9+
?>
10+
--EXPECT--
11+
bool(false)
12+
bool(false)
13+
int(0)
14+
int(0)

0 commit comments

Comments
 (0)