Skip to content

Fix #78751: Serialising DatePeriod converts DateTimeImmutable #4859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Oct 25, 2019

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.


I have targetted 7.4 to avoid any BC issues, but actually I think this should go into 7.2+.

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.
@cmb69 cmb69 requested a review from derickr October 25, 2019 12:45
@cmb69 cmb69 changed the base branch from master to PHP-7.4 October 25, 2019 13:06
@@ -5260,7 +5260,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)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be safe as the DateTimeInterface can not be implemented by user land functions, right? Because if it can, this might not work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right.

@nikic
Copy link
Member

nikic commented Oct 28, 2019

I have targetted 7.4 to avoid any BC issues, but actually I think this should go into 7.2+.

I agree that it should go as a bug fix into 7.2.

@cmb69
Copy link
Member Author

cmb69 commented Oct 28, 2019

Thanks! Applied as 89c327f (PHP 7.2+)

@cmb69 cmb69 closed this Oct 28, 2019
@cmb69 cmb69 deleted the fix-78751 branch October 28, 2019 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants