Dmitry Kiselev created THRIFT-2950:
--------------------------------------
Summary: Thrift's PHP generated entity does not serialize SET type
correctly
Key: THRIFT-2950
URL: https://issues.apache.org/jira/browse/THRIFT-2950
Project: Thrift
Issue Type: Bug
Reporter: Dmitry Kiselev
idl:
{noformat}
struct TTestEntity {
1: string id
2: set<string> data
}
{noformat}
php code generation works okay and we can set data
{noformat}
$entity = new TTestEntity();
$entity->id = "hello";
$entity->data = array("element1", "element2");
$buffer = new TMemoryBuffer();
$entity->write(new TJSONProtocol($buffer));
echo $buffer->getBuffer();
{noformat}
but resulting JSON does not contain the set elements values:
{noformat}
{"1":{"str":"hello"},"2":{"set":["str",2,0,1]}}
{noformat}
If found the code generated by thrift that creates writes a string for SET:
{code}
foreach ($this->collection as $iter6 => $iter7)
{
if (is_scalar($iter7)) {
$xfer += $output->writeString($iter6);
} else {
$xfer += $output->writeString($iter7);
}
}
{code}
I can't explain why there is a check for is_scalar, but when array item value
is string, number or boolean it writes array item key instead of value.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)