Skip over uninitialized properties when serializing#250
Skip over uninitialized properties when serializing#250TysonAndre merged 1 commit intoigbinary:masterfrom
Conversation
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;}" |
There was a problem hiding this comment.
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 checked https://wiki.php.net/rfc/typed_properties_v2 , https://externals.io/message/102333 , and https://externals.io/message/103148 , and didn't see any references to __sleep (just "I wouldn't lose sleep
if we wanted to keep the GA date where it is.")
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)
This fixes an error when unserializing php 7.4 typed properties.
Fixes #249