Merge branch 'PHP-7.4'

* PHP-7.4:
  Fix #78751: Serialising DatePeriod converts DateTimeImmutable
This commit is contained in:
Christoph M. Becker 2019-10-28 13:09:44 +01:00
commit f9a98f6dbd
2 changed files with 22 additions and 6 deletions

View File

@ -4793,7 +4793,7 @@ static HashTable *date_object_get_properties_period(zend_object *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 {
@ -4803,7 +4803,7 @@ static HashTable *date_object_get_properties_period(zend_object *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 {
@ -4813,7 +4813,7 @@ static HashTable *date_object_get_properties_period(zend_object *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 {
@ -4850,7 +4850,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);
@ -4864,7 +4864,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);
@ -4877,7 +4877,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);

View File

@ -0,0 +1,16 @@
--TEST--
Bug #78751 (Serialising DatePeriod converts DateTimeImmutable)
--FILE--
<?php
$oDay = new DateTimeImmutable('2019-10-25');
$oDateInterval = DateInterval::createFromDateString('1 day');
$oDays = new DatePeriod($oDay, $oDateInterval, $oDay->modify('+1 day'));
$oDays = unserialize(serialize($oDays));
var_dump(
$oDays->start instanceof DateTimeImmutable,
$oDays->end instanceof DateTimeImmutable
);
?>
--EXPECT--
bool(true)
bool(true)