GitHub user sashakavun opened a pull request:
https://github.com/apache/thrift/pull/1042
THRIFT-3874 PHP Compiler: struct definition is not populated on type
classes de-serialization
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.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/sashakavun/thrift
THRIFT-3874-php-gen-wakeup-tspec-population
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/1042.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1042
----
commit d4b8e4639ac50228ef1480e424f04800783c52f1
Author: Sasha Kavun <[email protected]>
Date: 2016-07-08T22:34:18Z
THRIFT-3874 PHP Compiler: struct definition is not populated on type
classes de-serialization
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---