You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Dmitry Kiselev (JIRA)" <ji...@apache.org> on 2015/02/06 11:08:34 UTC
[jira] [Commented] (THRIFT-2950) Thrift's PHP generated entity does
not serialize SET type correctly
[ https://issues.apache.org/jira/browse/THRIFT-2950?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14308933#comment-14308933 ]
Dmitry Kiselev commented on THRIFT-2950:
----------------------------------------
Could someone take a look on this bug and explain this behavior? That's very important.
> 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)