[ 
https://issues.apache.org/jira/browse/THRIFT-1279?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bryan Duxbury updated THRIFT-1279:
----------------------------------

    Fix Version/s:     (was: 0.7)
                   0.8

> type set is handled incorrectly when writing object
> ---------------------------------------------------
>
>                 Key: THRIFT-1279
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1279
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Compiler, PHP - Library
>    Affects Versions: 0.7
>            Reporter: Darius Staisiunas
>             Fix For: 0.8
>
>         Attachments: thrift-1279.patch
>
>
> Patch provided in https://issues.apache.org/jira/browse/THRIFT-342 doesn't 
> handle object writing correctly:
> if one of the parameters is set
> struct MyStruct {
>     10: string id,
>     20: string name,
>     30: set<string> setOfIDs
> }
> in generated file de-serialization of object is
> public function read($input)
> ...
> $xfer += $input->readString($elem5);
> if (is_scalar($elem5)) {
>   $this->setOfIDs[$elem5] = true;
> } else {
>   $this->setOfIDs []= $elem5;
> }
> ...
> but when serializing, we are looping only through values of array:
> public function write($input) 
> ...
> foreach ($this->setOfIDs as $iter6)
> {
>   if (is_scalar($iter6)) {
>     $this->setOfIDs[$iter6] = true;
>   }
>     $xfer += $output->writeString($iter6);
>   }
> }
> ...
> But if our element is scalar - we should be iterating through keys.
> it should look like:
> foreach ($this->terminalIds as $iter6 => $iter7)
> {
>   if (is_scalar($iter7)) {
>     $xfer += $output->writeString($iter6);
>   } else {
>     $xfer += $output->writeString($iter7);
>   }
> }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to