diff options
author | Paul Yang <TeBoring@users.noreply.github.com> | 2017-05-29 22:04:20 -0700 |
---|---|---|
committer | Bo Yang <teboring@google.com> | 2017-06-20 15:06:40 -0700 |
commit | c344fe8caa6da817d3f0ece0babf1d1acbf2bbbf (patch) | |
tree | 508ba4a5484aab9ae5a9328d75ad53096ad7948b /php/src/Google | |
parent | dba8928ff53ae372bba3d928a6145754a97238d5 (diff) | |
download | protobuf-c344fe8caa6da817d3f0ece0babf1d1acbf2bbbf.tar.gz protobuf-c344fe8caa6da817d3f0ece0babf1d1acbf2bbbf.tar.bz2 protobuf-c344fe8caa6da817d3f0ece0babf1d1acbf2bbbf.zip |
Oneof field should be serialized even it's equal to default. (#3153)
Diffstat (limited to 'php/src/Google')
-rw-r--r-- | php/src/Google/Protobuf/Internal/Message.php | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/php/src/Google/Protobuf/Internal/Message.php b/php/src/Google/Protobuf/Internal/Message.php index cd15e0f0..10c639ac 100644 --- a/php/src/Google/Protobuf/Internal/Message.php +++ b/php/src/Google/Protobuf/Internal/Message.php @@ -739,6 +739,13 @@ class Message */ private function existField($field) { + $oneof_index = $field->getOneofIndex(); + if ($oneof_index !== -1) { + $oneof = $this->desc->getOneofDecl()[$oneof_index]; + $oneof_name = $oneof->getName(); + return $this->$oneof_name->getNumber() === $field->getNumber(); + } + $getter = $field->getGetter(); $value = $this->$getter(); return $value !== $this->defaultValue($field); |