[ https://issues.apache.org/jira/browse/THRIFT-3874?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15368618#comment-15368618 ]
ASF GitHub Bot commented on THRIFT-3874: ---------------------------------------- GitHub user sashakavun opened a pull request: https://github.com/apache/thrift/pull/1041 THRIFT-3874 PHP Compiler: struct definition is not populated on type classes de-serialization 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/1041.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 #1041 ---- commit 1c616ce71d0836ff4f2bd53ecc12548fbee6a6fd Author: Sasha Kavun <i...@sashakavun.ru> Date: 2016-07-08T22:34:18Z THRIFT-3874 PHP Compiler: struct definition is not populated on type classes de-serialization ---- > _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 > Attachments: php-gen-wakeup-fix.patch > > > 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 (v6.3.4#6332)