Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
0.7
-
None
-
Patch Available
Description
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))
$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))
else
{ $xfer += $output->writeString($iter7); }}