Fix PHP serialization for classes implementing serializable interface #552
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When
PxCDMWebTrackerSessionIdentifier
was serialized, PHP'sserialize()
function used serialization handlers instead of the PHP class'sserialize()
method, producing incompatible data:During deserialization, this caused:
When PHP's
serialize()
was called, it found and used handlers (ClassImpl::serialize
andClassImpl::unserialize
), bypassing the PHP method table. These handlers directly calledSerializable::serialize()
and produced binary data that was incompatible with what the PHP class'sunserialize()
method expected to receive.Solution
In this project, we remove the use of serialization handlers from classimpl.cpp and changed the PHP method names. By removing the use of these handlers and updating the method names, PHP's
serialize()
now correctly uses the methods registered in the PHP function table. These methods callBase::serialize
which bridges to the C++Serializable
interface, allowing the PHP class'sserialize()
method to execute and produce the expected serialized format that itsunserialize()
method can correctly parse.