Closed TRowbotham closed 2 years ago
Excellent job, thank you! :+1:
Actually, I'm realizing that this is somehow a BC break, because the serialized string is different (people may store serialized strings in database for example, so unserialization may break after this change), so this will need to go into the next version, 0.10.0
.
I'm hesitating between releasing 0.10
now, with just this change, or waiting for 6 December when support for PHP 7.3 will be dropped, and making PHP 7.4 the minimum version and dropping Serializable
at the same time.
PHP 8.1 should be released somewhere around 25 November, so the timing may be good to do everything at the same time.
What do you think?
That's a good question! I wasn't sure, so I checked the RFC and, assuming I'm understanding it correctly, this is actually not a BC break so long as the objects continue to implement Serializable
. So, I think it would be fine if you released a new version now, which would potentially give developers time to convert any older serialized forms that they may have stored to the new version.
If a class both implements Serializable and serialize()/unserialize(), then serialization will prefer the new mechanism, while unserialization can make use of either, depending on whether the C (Serializable) or O (__unserialize) format is used. As such, old serialized strings encoded in C format can still be decoded, while new strings will be produced in O format.
I guess it is a BC break if you cannot serialize an object with one version and unserialize it with the next version?
Now that I think about it, it's actually making things worse if I release a version that's compatible with both serialization methods at the same time. Think about it:
serialize()
), store it in the DB__unserialize()
) from the DB : boom 💥Oh wow, scratch that. I read your comment but not the quoted string. So you're right, it's absolutely not a BC break.
It will eventually become a BC break when Serializable
gets removed from the language, but that may not be until PHP 9 or later.
I will have dropped support for PHP < 7.4 and therefore Serializable
before then ;-)
This adds support for the custom object serialization feature added in PHP 7.4. This is needed to suppress deprecation warnings in PHP 8.1 since the
Serializable
interface is now deprecated.