Thrift-1279: type set is handled incorrectly when writing object
Client: php
Patch: Darius Staisiunas
Fixes issue to iIterate through scalar types correctly.
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1165703 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_php_generator.cc b/compiler/cpp/src/generate/t_php_generator.cc
index 2ca1d6f..6d8fd88 100644
--- a/compiler/cpp/src/generate/t_php_generator.cc
+++ b/compiler/cpp/src/generate/t_php_generator.cc
@@ -2136,13 +2136,15 @@
scope_down(out);
} else if (ttype->is_set()) {
string iter = tmp("iter");
+ string iter_val = tmp("iter");
indent(out) <<
- "foreach ($" << prefix << " as $" << iter << ")" << endl;
+ "foreach ($" << prefix << " as $" << iter << " => $" << iter_val << ")" << endl;
scope_up(out);
- indent(out) << "if (is_scalar($" << iter << ")) {" << endl <<
- indent() << " $" << prefix << "[$" << iter << "] = true;" << endl <<
- indent() << "}" << endl;
+ indent(out) << "if (is_scalar($" << iter_val << ")) {" << endl;
generate_serialize_set_element(out, (t_set*)ttype, iter);
+ indent(out) << "} else {" << endl;
+ generate_serialize_set_element(out, (t_set*)ttype, iter_val);
+ indent(out) << "}" << endl;
scope_down(out);
} else if (ttype->is_list()) {
string iter = tmp("iter");