diff options
| author | Paul Yang <TeBoring@users.noreply.github.com> | 2019-07-08 14:20:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-08 14:20:46 -0700 |
| commit | 864bd030cf60e0ae037fc4c734f86542532e479d (patch) | |
| tree | d084ac5b239c1b3e1d3da58b3f0c8efef97fd545 /php/ext | |
| parent | f1ecf5c0ccfe700e4df23ce0c9ea558cb6442e43 (diff) | |
| download | platform_external_protobuf-864bd030cf60e0ae037fc4c734f86542532e479d.tar.gz platform_external_protobuf-864bd030cf60e0ae037fc4c734f86542532e479d.tar.bz2 platform_external_protobuf-864bd030cf60e0ae037fc4c734f86542532e479d.zip | |
Set oneof case in array constructor (#6351)
Forgot to set it previously.
Diffstat (limited to 'php/ext')
| -rw-r--r-- | php/ext/google/protobuf/message.c | 3 | ||||
| -rw-r--r-- | php/ext/google/protobuf/protobuf.h | 2 | ||||
| -rw-r--r-- | php/ext/google/protobuf/storage.c | 4 |
3 files changed, 7 insertions, 2 deletions
diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index 43561551b..f147325bb 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -469,11 +469,14 @@ void Message_construct(zval* msg, zval* array_wrapper) { if (upb_fielddef_containingoneof(field)) { void* memory = slot_memory(intern->descriptor->layout, message_data(intern), field); + uint32_t* oneof_case = slot_oneof_case(intern->descriptor->layout, + message_data(intern), field); int property_cache_index = intern->descriptor->layout->fields[upb_fielddef_index(field)] .cache_index; cached = OBJ_PROP(Z_OBJ_P(msg), property_cache_index); *(CACHED_VALUE**)(memory) = cached; + *oneof_case = upb_fielddef_number(field); } else { zend_property_info* property_info; PHP_PROTO_FAKE_SCOPE_BEGIN(Z_OBJCE_P(msg)); diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index b2a9b94c8..4e922ba9c 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -948,6 +948,8 @@ void layout_merge(MessageLayout* layout, MessageHeader* from, const char* layout_get_oneof_case(MessageLayout* layout, const void* storage, const upb_oneofdef* oneof TSRMLS_DC); void free_layout(MessageLayout* layout); +uint32_t* slot_oneof_case(MessageLayout* layout, const void* storage, + const upb_fielddef* field); void* slot_memory(MessageLayout* layout, const void* storage, const upb_fielddef* field); diff --git a/php/ext/google/protobuf/storage.c b/php/ext/google/protobuf/storage.c index 8f717302d..1c28b1c18 100644 --- a/php/ext/google/protobuf/storage.c +++ b/php/ext/google/protobuf/storage.c @@ -572,8 +572,8 @@ static size_t align_up_to(size_t offset, size_t granularity) { return (offset + granularity - 1) & ~(granularity - 1); } -static uint32_t* slot_oneof_case(MessageLayout* layout, const void* storage, - const upb_fielddef* field) { +uint32_t* slot_oneof_case(MessageLayout* layout, const void* storage, + const upb_fielddef* field) { return (uint32_t*)(((uint8_t*)storage) + layout->fields[upb_fielddef_index(field)].case_offset); } |
