Skip to content

Skip non-existing properties returned by __sleep() #5413

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 1 commit into from

Conversation

nicolas-grekas
Copy link
Contributor

Serializing a null for properties that don't exist makes no sense.
Better skip them.

I think this old behavior was due to a pure side effect of the implementation, which has been fixed in 90fea67 and can now be fixed.

@TysonAndre
Copy link
Contributor

This seems like an improvement, and would be consistent with the other PR being worked on to omit uninitialized&unset declared typed properties from __sleep.

If there was a need in an application to serialize a literal null, then __serialize is available in 7.4 as an alternative - I'd assume most application writers that had notices enabled would fix the notices.

It should be noted in UPGRADING afterwards if this gets merged, though.

Would like to hear what @nikic and others think

@nikic
Copy link
Member

nikic commented Apr 19, 2020

I agree that this change makes sense. I think it would be safer to land it in master only though, assuming there is no particular urgency to make the change.

@nicolas-grekas nicolas-grekas changed the base branch from PHP-7.4 to master April 19, 2020 09:48
@nicolas-grekas
Copy link
Contributor Author

Works for me, now rebased on master.

@cmb69
Copy link
Member

cmb69 commented Apr 22, 2020

Thanks! Applied as 657f756.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants