aboutsummaryrefslogtreecommitdiff
path: root/php/ext/google
diff options
context:
space:
mode:
authorPaul Yang <TeBoring@users.noreply.github.com>2017-06-20 22:53:22 -0700
committerGitHub <noreply@github.com>2017-06-20 22:53:22 -0700
commit8ecae34ac65218e9fda1586abc39f8762dbb40de (patch)
treef5ebd70dd889b94872f0e4fe75704d21998dd4cd /php/ext/google
parentbf04c83267619b618e7112b242f424f8b3e785b6 (diff)
parent3b1a87518cead7403b8e13c41945e41a30d602e4 (diff)
downloadprotobuf-8ecae34ac65218e9fda1586abc39f8762dbb40de.tar.gz
protobuf-8ecae34ac65218e9fda1586abc39f8762dbb40de.tar.bz2
protobuf-8ecae34ac65218e9fda1586abc39f8762dbb40de.zip
Merge pull request #3255 from TeBoring/3.3.x-3
Cherry-pick bug fixes for php
Diffstat (limited to 'php/ext/google')
-rw-r--r--php/ext/google/protobuf/def.c4
-rw-r--r--php/ext/google/protobuf/encode_decode.c4
-rw-r--r--php/ext/google/protobuf/message.c1
3 files changed, 5 insertions, 4 deletions
diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c
index 8e563a61..099ebd05 100644
--- a/php/ext/google/protobuf/def.c
+++ b/php/ext/google/protobuf/def.c
@@ -30,8 +30,8 @@
#include "protobuf.h"
-const char* const kReservedNames[] = {"Empty"};
-const int kReservedNamesSize = 1;
+const char* const kReservedNames[] = {"Empty", "ECHO", "ARRAY"};
+const int kReservedNamesSize = 3;
// Forward declare.
static void descriptor_init_c_instance(Descriptor* intern TSRMLS_DC);
diff --git a/php/ext/google/protobuf/encode_decode.c b/php/ext/google/protobuf/encode_decode.c
index 28bf18f4..6e3c606b 100644
--- a/php/ext/google/protobuf/encode_decode.c
+++ b/php/ext/google/protobuf/encode_decode.c
@@ -1167,6 +1167,7 @@ static void putrawmsg(MessageHeader* msg, const Descriptor* desc,
upb_msg_field_next(&i)) {
upb_fielddef* f = upb_msg_iter_field(&i);
uint32_t offset = desc->layout->fields[upb_fielddef_index(f)].offset;
+ bool containing_oneof = false;
if (upb_fielddef_containingoneof(f)) {
uint32_t oneof_case_offset =
@@ -1179,6 +1180,7 @@ static void putrawmsg(MessageHeader* msg, const Descriptor* desc,
}
// Otherwise, fall through to the appropriate singular-field handler
// below.
+ containing_oneof = true;
}
if (is_map_field(f)) {
@@ -1209,7 +1211,7 @@ static void putrawmsg(MessageHeader* msg, const Descriptor* desc,
#define T(upbtypeconst, upbtype, ctype, default_value) \
case upbtypeconst: { \
ctype value = DEREF(message_data(msg), offset, ctype); \
- if (value != default_value) { \
+ if (containing_oneof || value != default_value) { \
upb_sink_put##upbtype(sink, sel, value); \
} \
} break;
diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c
index 48b87b10..1162a5f8 100644
--- a/php/ext/google/protobuf/message.c
+++ b/php/ext/google/protobuf/message.c
@@ -30,7 +30,6 @@
#include <php.h>
#include <stdlib.h>
-#include <ext/json/php_json.h>
#include "protobuf.h"