[
https://issues.apache.org/jira/browse/THRIFT-3874?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sylwester Lachiewicz resolved THRIFT-3874.
------------------------------------------
Fix Version/s: 0.24.0
Resolution: Fixed
Resolving, though not by the route this ticket proposed - PRs #1041 and #1042
were both closed unmerged.
The generator now emits {{public static array $tspec}} on each struct instead
of an instance member, so the spec is class-level state that {{unserialize()}}
cannot drop. That makes the reported failure structurally impossible rather
than repaired. {{TBase::__wakeup()}} is now an explicit no-op with a comment
explaining why. Landed under THRIFT-5991 in {{df8cc08ae}}, first released in
0.24.0.
PR #3795 added regression coverage in
{{BinarySerializerTest::testBinarySerializerAfterPhpUnserialize}}.
_This comment was created with AI assistance._
> _TSPEC is not populated on de-serialization of type classes
> -----------------------------------------------------------
>
> Key: THRIFT-3874
> URL: https://issues.apache.org/jira/browse/THRIFT-3874
> Project: Thrift
> Issue Type: Bug
> Components: PHP - Compiler
> Affects Versions: 0.9.3
> Reporter: Aleksandr Kavun
> Assignee: Volodymyr Panivko
> Priority: Major
> Fix For: 0.24.0
>
> Time Spent: 50m
> Remaining Estimate: 0h
>
> When type class which was serialized and deserialized by internal PHP
> functions (for example, if data was stored to memcache and then retrieved) is
> used in requests, thrift_extension gives an 'Attempt to send non-Thrift
> object as a T_STRUCT' error.
> This is because thrift_extension binary_serialize() function is tries to
> access to the $_TSPEC static property of object to determine it's target
> structure. Static $_TSPEC array for generated PHP classes is populated in
> __construct(). But when objects are deserialized, __construct() isn't called,
> instead of that PHP calls __wakeup() function. So type class should be
> instantiated once before sending it via Thrift.
> The solution is to move code that populates $_TSPEC out of constructor to the
> generic function, and call this function both in __construct() and __wakeup()
> functions.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)