You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Noticed when running pecl install ds then checking by evaluating php snippets to see if php-ds allowed dynamic properties (ce_flags ZEND_ACC_NO_DYNAMIC_PROPERTIES - apparently, it allows them) and whether it bothers serializing dynamic properties (it doesn't), since this type of behavior usually isn't documented on php.net
(I'm not requesting supporting serializing dynamic properties or changes to property behavior, I wanted to know if php-ds made a design choice to reject dynamic properties, especially with https://wiki.php.net/rfc/deprecate_dynamic_properties recently being proposed)
In PHP 9.0 the Serializable interface will be removed and unserialize() will reject payloads using the C serialization format. Code needing to support both PHP < 7.4 and PHP >= 9.0 may polyfill the Serializable interface, though it will have no effect on serialization.
For users that are migrating from an older php version (and php-ds installation) to php 9.0 in the future, it would be useful to support __unserialize in one release (and switch the way structures are serialized to __serialize in a later release). When implementing __unserialize, one edge case that needs to be handled is checking if the data is already unserialized.
__unserialize requires php 7.4+ to work. In older versions, the array data being unserialized is added as object properties instead. __wakeup can be used inconveniently in php versions prior to 7.4 to some extent to try to convert those dynamic properties back to a well-formed collection, but I've never seen anything that does that, so I'm not certain of the difficulty
E.g. data structures might be serialized and saved in/loaded from memcache/redis, and users may run both php 8.1 and 9.0 at the same time, and making sure that php 8.1 could read the data written by 9.0 would be useful
(I'm one of the maintainers of igbinary, I should be able to answer questions about serialization/unserialization in general. Note that igbinary probably does not work with php-ds's use of Serializable design for edge cases such as object reuse, cyclic data structures, etc)
php-src/ext/spl/ or other libraries can be used as a reference for how to implement an __unserialize method in a datastructure.
The text was updated successfully, but these errors were encountered:
Noticed when running
pecl install ds
then checking by evaluating php snippets to see if php-ds allowed dynamic properties (ce_flags ZEND_ACC_NO_DYNAMIC_PROPERTIES - apparently, it allows them) and whether it bothers serializing dynamic properties (it doesn't), since this type of behavior usually isn't documented on php.net(I'm not requesting supporting serializing dynamic properties or changes to property behavior, I wanted to know if php-ds made a design choice to reject dynamic properties, especially with https://wiki.php.net/rfc/deprecate_dynamic_properties recently being proposed)
https://wiki.php.net/rfc/phase_out_serializable mentions that Serializable and the
C:
serialization format will be phased out in php 9.0For users that are migrating from an older php version (and php-ds installation) to php 9.0 in the future, it would be useful to support
__unserialize
in one release (and switch the way structures are serialized to__serialize
in a later release). When implementing__unserialize
, one edge case that needs to be handled is checking if the data is already unserialized.__unserialize
requires php 7.4+ to work. In older versions, the array data being unserialized is added as object properties instead.__wakeup
can be used inconveniently in php versions prior to 7.4 to some extent to try to convert those dynamic properties back to a well-formed collection, but I've never seen anything that does that, so I'm not certain of the difficulty(I'm one of the maintainers of
igbinary
, I should be able to answer questions about serialization/unserialization in general. Note that igbinary probably does not work with php-ds's use ofSerializable
design for edge cases such as object reuse, cyclic data structures, etc)php-src/ext/spl/ or other libraries can be used as a reference for how to implement an
__unserialize
method in a datastructure.The text was updated successfully, but these errors were encountered: