Add fallback hydration for properties#411
Add fallback hydration for properties#411madmajestro wants to merge 1 commit intoigbinary:masterfrom
Conversation
|
I would suggest adding another test where both |
src/php7/igbinary.c
Outdated
| int mangle_property_names = 0; | ||
|
|
||
| #if PHP_VERSION_ID >= 80000 | ||
| if (ce->__serialize) mangle_property_names = 1; |
There was a problem hiding this comment.
Have not yet reviewed actual substance yet, but for style consistency; please use an explicit comparison and braces:
if (ce->__serialize != NULL) {
...
}
Also please use tabs for indentation.
There was a problem hiding this comment.
I'm now using an explicit comparison and curly braces, but I've already used tabs in the C code and spaces in the PHPT tests, just like the other __serialize*.phpt tests do. Should I still use tabs in the tests?
Indeed this is very much required, though there are quite a few tests already. Tests can always be improved. |
157ec93 to
3973a6a
Compare
|
I've added a test to check the behavior of |
3973a6a to
7e01f54
Compare
|
I have just pushed an optimized version. This version uses the mangled representation of the property name already present in zend_property_info. This saves the memory allocation and string copying done in |
7e01f54 to
31f2cf3
Compare
|
@tricky |
31f2cf3 to
b15eb2a
Compare
|
I have now implemented the fallback hydration, as it exists in PHP's internal serializer since PHP 7.2. This should resolve several issues. In addition, the behavior of igbinary hopefully should now be identical to PHP's serializer, allowing it to be used again as a drop-in replacement. |
b15eb2a to
1d0cb26
Compare
|
@tricky |
If the visibility of a property has changed between serialization and unserialization, or if a private or protected property needs to be restored, but the serialized data was generated by a __serialize method while no __unserialize method exists in the class, the property value cannot be found during hydration in the object's hash table. The reason for this is that in these cases the property name in the serialized representation does not match the prefixed/mangled property name of the current class definition. To resolve this, an attempt is made to determine the correctly prefixed property name by performing a lookup with the unprefixed property name in the properties_info hash table of the class. This aligns the behavior to the serializer of PHP >= 7.2.
1d0cb26 to
a78b797
Compare
|
I've re-analyzed the behavior of the PHP serializer and Igbinary once more and noticed a few edge cases where PHP and Igbinary behaved differently. I've fixed these issues and added / revised tests so that the behavior of PHP and Igbinary is now tested and compared during the tests. I hope this simplifies the review process and helps to identify differences between PHP and Igbinary in the future. |
If the visibility of a property has changed between serialization and unserialization, or if a private or protected property needs to be restored, but the serialized data was generated by a __serialize method while no __unserialize method exists in the class, the property value cannot be found during hydration in the object's hash table. The reason for this is that in these cases the property name in the serialized representation does not match the prefixed/mangled property name of the current class definition. To resolve this, an attempt is made to determine the correctly prefixed property name by performing a lookup with the unprefixed property name in the properties_info hash table of the class. This aligns the behavior to the serializer of PHP >= 7.2.
Closes #410
Closes #387
Closes #156