summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2019-10-18 15:31:48 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2019-10-18 15:32:08 +0200
commitc7c7ab53ac28fc64625511e1c2be37036f5f89c1 (patch)
tree6a3f03c34c279d1bcfdb39fd5a29cef68fadb2f3
parent3725a446ba8a176563f10998b59e940daf3cec62 (diff)
parentd2cde0bfd39422be3af49f6513a0a5358ef7cf63 (diff)
downloadphp-git-c7c7ab53ac28fc64625511e1c2be37036f5f89c1.tar.gz
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fix #70153 \DateInterval incorrectly unserialized
-rw-r--r--NEWS3
-rw-r--r--ext/date/php_date.c16
-rw-r--r--ext/date/tests/bug48678.phpt2
-rw-r--r--ext/date/tests/bug53437.phpt2
-rw-r--r--ext/date/tests/bug53437_var2.phpt2
-rw-r--r--ext/date/tests/bug70153.phpt14
6 files changed, 35 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 1cc48b34e8..b7fa7a2f8a 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ PHP NEWS
. Fixed bug #78656 (Parse errors classified as highest log-level). (Erik
Lundin)
+- Date:
+ . Fixed bug #70153 (\DateInterval incorrectly unserialized). (Maksim Iakunin)
+
- Iconv:
. Fixed bug #78642 (Wrong libiconv version displayed). (gedas at martynas,
cmb).
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 1a1f6e2b35..49df94f592 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -4359,6 +4359,20 @@ static int php_date_interval_initialize_from_hash(zval **return_value, php_inter
} \
} while (0);
+#define PHP_DATE_INTERVAL_READ_PROPERTY_DAYS(member) \
+ do { \
+ zval *z_arg = zend_hash_str_find(myht, "days", sizeof("days") - 1); \
+ if (z_arg && Z_TYPE_P(z_arg) == IS_FALSE) { \
+ (*intobj)->diff->member = -99999; \
+ } else if (z_arg && Z_TYPE_P(z_arg) <= IS_STRING) { \
+ zend_string *str = zval_get_string(z_arg); \
+ DATE_A64I((*intobj)->diff->member, ZSTR_VAL(str)); \
+ zend_string_release(str); \
+ } else { \
+ (*intobj)->diff->member = -1LL; \
+ } \
+ } while (0);
+
#define PHP_DATE_INTERVAL_READ_PROPERTY_DOUBLE(element, member, def) \
do { \
zval *z_arg = zend_hash_str_find(myht, element, sizeof(element) - 1); \
@@ -4387,7 +4401,7 @@ static int php_date_interval_initialize_from_hash(zval **return_value, php_inter
PHP_DATE_INTERVAL_READ_PROPERTY("weekday_behavior", weekday_behavior, int, -1)
PHP_DATE_INTERVAL_READ_PROPERTY("first_last_day_of", first_last_day_of, int, -1)
PHP_DATE_INTERVAL_READ_PROPERTY("invert", invert, int, 0);
- PHP_DATE_INTERVAL_READ_PROPERTY_I64("days", days);
+ PHP_DATE_INTERVAL_READ_PROPERTY_DAYS(days);
PHP_DATE_INTERVAL_READ_PROPERTY("special_type", special.type, unsigned int, 0);
PHP_DATE_INTERVAL_READ_PROPERTY_I64("special_amount", special.amount);
PHP_DATE_INTERVAL_READ_PROPERTY("have_weekday_relative", have_weekday_relative, unsigned int, 0);
diff --git a/ext/date/tests/bug48678.phpt b/ext/date/tests/bug48678.phpt
index 4f3b51d5b1..c02dba11cf 100644
--- a/ext/date/tests/bug48678.phpt
+++ b/ext/date/tests/bug48678.phpt
@@ -39,7 +39,7 @@ DateInterval Object
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 0
- [days] => 0
+ [days] =>
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
diff --git a/ext/date/tests/bug53437.phpt b/ext/date/tests/bug53437.phpt
index 3e5899057d..cac93a2ef0 100644
--- a/ext/date/tests/bug53437.phpt
+++ b/ext/date/tests/bug53437.phpt
@@ -136,7 +136,7 @@ object(DatePeriod)#%d (6) {
["invert"]=>
int(0)
["days"]=>
- int(0)
+ bool(false)
["special_type"]=>
int(0)
["special_amount"]=>
diff --git a/ext/date/tests/bug53437_var2.phpt b/ext/date/tests/bug53437_var2.phpt
index 2ef21e738e..51cc28943b 100644
--- a/ext/date/tests/bug53437_var2.phpt
+++ b/ext/date/tests/bug53437_var2.phpt
@@ -71,7 +71,7 @@ object(DateInterval)#2 (16) {
["invert"]=>
int(0)
["days"]=>
- int(0)
+ bool(false)
["special_type"]=>
int(0)
["special_amount"]=>
diff --git a/ext/date/tests/bug70153.phpt b/ext/date/tests/bug70153.phpt
new file mode 100644
index 0000000000..5b965207fc
--- /dev/null
+++ b/ext/date/tests/bug70153.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #70153 (\DateInterval incorrectly unserialized)
+--FILE--
+<?php
+$i1 = \DateInterval::createFromDateString('+1 month');
+$i2 = unserialize(serialize($i1));
+var_dump($i1->days, $i2->days);
+var_dump($i2->special_amount, $i2->special_amount);
+?>
+--EXPECT--
+bool(false)
+bool(false)
+int(0)
+int(0)