Skip to content

Skip over uninitialized properties when serializing#250

Merged
TysonAndre merged 1 commit intoigbinary:masterfrom
TysonAndre:fix-unserialize-uninitialized
Dec 10, 2019
Merged

Skip over uninitialized properties when serializing#250
TysonAndre merged 1 commit intoigbinary:masterfrom
TysonAndre:fix-unserialize-uninitialized

Conversation

@TysonAndre
Copy link
Member

This fixes an error when unserializing php 7.4 typed properties.

Fixes #249

This fixes an error when unserializing php 7.4 typed properties.

Fixes igbinary#249
serialize(): "o" returned as member variable from __sleep() but does not exist
serialize(): "s" returned as member variable from __sleep() but does not exist
serialize(): "i" returned as member variable from __sleep() but does not exist
string(44) "O:3:"OSI":3:{s:1:"o";N;s:1:"s";N;s:1:"i";N;}"
Copy link
Member Author

@TysonAndre TysonAndre Dec 10, 2019

Choose a reason for hiding this comment

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

I didn't see any mention of how uninitialized typed properties should behave for __sleep in the RFC or RFC/PR discussion. Right now, because igbinary's igbinary_serialize() is based on php's serialize() (which serializes nulls), it has the exact same TypeError on igbinary_unserialize()

Is the current behavior in 7.4 and 8.0-dev for __sleep on uninitialized properties by design, or is it an edge case that was overlooked? It seems surprising that data serializes successfully, but throws when it gets unserialized for the same class declaration.

I also didn't see any mention of __sleep in php/php-src#3734 , or in the changes of the PR. (or in https://bugs.php.net/search.php?cmd=display&search_for=__sleep+AND+uninitialized&order_by=ts1&direction=ASC&limit=30&status=Open&reorder_by=ts2 )

cc @nikic @bwoebi @krakjoe @dstogov (co-authors of https://github.com/php/php-src/commit/e219ec144ef6682b71e135fd18654ee1bb4676b4)

Filed https://bugs.php.net/bug.php?id=79002

@TysonAndre TysonAndre merged commit e4e9acd into igbinary:master Dec 10, 2019
@TysonAndre TysonAndre deleted the fix-unserialize-uninitialized branch September 2, 2020 13:47
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.

Look for remaining edge cases with php 7.4 typed properties

1 participant