diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2019-10-25 15:43:38 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2019-10-28 13:07:28 +0100 |
commit | 89c327f8848c1a56a61479ee5e7fdd3694d0f867 (patch) | |
tree | e99f3428c88a0db482e8993afa784c454a75b5ce /ext/date/php_date.c | |
parent | 16c49108763db251151b350e433dde6d1a076250 (diff) | |
download | php-git-89c327f8848c1a56a61479ee5e7fdd3694d0f867.tar.gz |
Fix #78751: Serialising DatePeriod converts DateTimeImmutable
When getting the properties of a DatePeriod instance we have to retain
the proper classes, and when restoring a DatePeriod instance we have to
cater to DateTimeImmutable instances as well.
Diffstat (limited to 'ext/date/php_date.c')
-rw-r--r-- | ext/date/php_date.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index f82abc6486..fdf84f6056 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -5171,7 +5171,7 @@ static HashTable *date_object_get_properties_period(zval *object) /* {{{ */ if (period_obj->start) { php_date_obj *date_obj; - object_init_ex(&zv, date_ce_date); + object_init_ex(&zv, period_obj->start_ce); date_obj = Z_PHPDATE_P(&zv); date_obj->time = timelib_time_clone(period_obj->start); } else { @@ -5181,7 +5181,7 @@ static HashTable *date_object_get_properties_period(zval *object) /* {{{ */ if (period_obj->current) { php_date_obj *date_obj; - object_init_ex(&zv, date_ce_date); + object_init_ex(&zv, period_obj->start_ce); date_obj = Z_PHPDATE_P(&zv); date_obj->time = timelib_time_clone(period_obj->current); } else { @@ -5191,7 +5191,7 @@ static HashTable *date_object_get_properties_period(zval *object) /* {{{ */ if (period_obj->end) { php_date_obj *date_obj; - object_init_ex(&zv, date_ce_date); + object_init_ex(&zv, period_obj->start_ce); date_obj = Z_PHPDATE_P(&zv); date_obj->time = timelib_time_clone(period_obj->end); } else { @@ -5228,7 +5228,7 @@ static int php_date_period_initialize_from_hash(php_period_obj *period_obj, Hash ht_entry = zend_hash_str_find(myht, "start", sizeof("start")-1); if (ht_entry) { - if (Z_TYPE_P(ht_entry) == IS_OBJECT && Z_OBJCE_P(ht_entry) == date_ce_date) { + if (Z_TYPE_P(ht_entry) == IS_OBJECT && instanceof_function(Z_OBJCE_P(ht_entry), date_ce_interface)) { php_date_obj *date_obj; date_obj = Z_PHPDATE_P(ht_entry); period_obj->start = timelib_time_clone(date_obj->time); @@ -5242,7 +5242,7 @@ static int php_date_period_initialize_from_hash(php_period_obj *period_obj, Hash ht_entry = zend_hash_str_find(myht, "end", sizeof("end")-1); if (ht_entry) { - if (Z_TYPE_P(ht_entry) == IS_OBJECT && Z_OBJCE_P(ht_entry) == date_ce_date) { + if (Z_TYPE_P(ht_entry) == IS_OBJECT && instanceof_function(Z_OBJCE_P(ht_entry), date_ce_interface)) { php_date_obj *date_obj; date_obj = Z_PHPDATE_P(ht_entry); period_obj->end = timelib_time_clone(date_obj->time); @@ -5255,7 +5255,7 @@ static int php_date_period_initialize_from_hash(php_period_obj *period_obj, Hash ht_entry = zend_hash_str_find(myht, "current", sizeof("current")-1); if (ht_entry) { - if (Z_TYPE_P(ht_entry) == IS_OBJECT && Z_OBJCE_P(ht_entry) == date_ce_date) { + if (Z_TYPE_P(ht_entry) == IS_OBJECT && instanceof_function(Z_OBJCE_P(ht_entry), date_ce_interface)) { php_date_obj *date_obj; date_obj = Z_PHPDATE_P(ht_entry); period_obj->current = timelib_time_clone(date_obj->time); |