Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
43f8ae87
Unverified
Commit
43f8ae87
authored
Feb 14, 2019
by
Paul Yang
Committed by
GitHub
Feb 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix oneof message in array constructor (#5727)
parent
9e381c05
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
8 deletions
+34
-8
message.c
php/ext/google/protobuf/message.c
+20
-8
generated_class_test.php
php/tests/generated_class_test.php
+14
-0
No files found.
php/ext/google/protobuf/message.c
View file @
43f8ae87
...
...
@@ -366,17 +366,29 @@ void Message_construct(zval* msg, zval* array_wrapper) {
const
upb_msgdef
*
submsgdef
=
upb_fielddef_msgsubdef
(
field
);
PHP_PROTO_HASHTABLE_VALUE
desc_php
=
get_def_obj
(
submsgdef
);
Descriptor
*
desc
=
UNBOX_HASHTABLE_VALUE
(
Descriptor
,
desc_php
);
zend_property_info
*
property_info
;
PHP_PROTO_FAKE_SCOPE_BEGIN
(
Z_OBJCE_P
(
msg
));
CACHED_VALUE
*
cached
=
NULL
;
if
(
upb_fielddef_containingoneof
(
field
))
{
void
*
memory
=
slot_memory
(
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
;
}
else
{
zend_property_info
*
property_info
;
PHP_PROTO_FAKE_SCOPE_BEGIN
(
Z_OBJCE_P
(
msg
));
#if PHP_MAJOR_VERSION < 7
property_info
=
zend_get_property_info
(
Z_OBJCE_P
(
msg
),
&
key
,
true
TSRMLS_CC
);
property_info
=
zend_get_property_info
(
Z_OBJCE_P
(
msg
),
&
key
,
true
TSRMLS_CC
);
#else
property_info
=
zend_get_property_info
(
Z_OBJCE_P
(
msg
),
Z_STR_P
(
&
key
),
true
);
property_info
=
zend_get_property_info
(
Z_OBJCE_P
(
msg
),
Z_STR_P
(
&
key
),
true
);
#endif
PHP_PROTO_FAKE_SCOPE_END
;
CACHED_VALUE
*
cached
=
OBJ_PROP
(
Z_OBJ_P
(
msg
),
property_info
->
offset
);
PHP_PROTO_FAKE_SCOPE_END
;
cached
=
OBJ_PROP
(
Z_OBJ_P
(
msg
),
property_info
->
offset
);
}
#if PHP_MAJOR_VERSION < 7
SEPARATE_ZVAL_IF_NOT_REF
(
cached
);
#endif
...
...
php/tests/generated_class_test.php
View file @
43f8ae87
...
...
@@ -1447,6 +1447,20 @@ class GeneratedClassTest extends TestBase
}
}
public
function
testOneofMessageInArrayConstructor
()
{
$m
=
new
TestMessage
([
'oneof_message'
=>
new
Sub
(),
]);
}
public
function
testOneofStringInArrayConstructor
()
{
$m
=
new
TestMessage
([
'oneof_string'
=>
'abc'
,
]);
}
#########################################################
# Test message equals.
#########################################################
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment