| 62 | } |
| 63 | |
| 64 | public static function deserialize($string_object, $class_name, $buffer_size = 8192) |
| 65 | { |
| 66 | $transport = new TMemoryBuffer(); |
| 67 | $protocol = new TBinaryProtocolAccelerated($transport); |
| 68 | if (function_exists('thrift_protocol_read_binary')) { |
| 69 | // NOTE (t.heintz) TBinaryProtocolAccelerated internally wraps our TMemoryBuffer in a |
| 70 | // TBufferedTransport, so we have to retrieve it again or risk losing data when writing |
| 71 | // less than 512 bytes to the transport (see the comment there as well). |
| 72 | // @see THRIFT-1579 |
| 73 | $protocol->writeMessageBegin('', TMessageType::REPLY, 0); |
| 74 | $protocolTransport = $protocol->getTransport(); |
| 75 | $protocolTransport->write($string_object); |
| 76 | $protocolTransport->flush(); |
| 77 | |
| 78 | return thrift_protocol_read_binary($protocol, $class_name, $protocol->isStrictRead(), $buffer_size); |
| 79 | } else { |
| 80 | $transport->write($string_object); |
| 81 | $object = new $class_name(); |
| 82 | $object->read($protocol); |
| 83 | |
| 84 | return $object; |
| 85 | } |
| 86 | } |
| 87 | } |