From dadc95438ff732cb0c1d2961ce7bcf0d99d179b1 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Wed, 23 May 2018 18:14:34 -0700 Subject: Fix array constructor in c extension for compatibility (#4667) In old generated code, the constructor of message doesn't provide a default null to parent's constructor. Previously, in c extesnion, this case was not handled. --- php/ext/google/protobuf/message.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'php') diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index 69012871..e28e42a1 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -387,9 +387,9 @@ void Message_construct(zval* msg, zval* array_wrapper) { // object. Here, we manually modify it to our message in such a case. PHP_METHOD(Message, __construct) { // Init message with array - zval* array_wrapper; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a!", &array_wrapper, - message_type) == FAILURE) { + zval* array_wrapper = NULL; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, + "|a!", &array_wrapper) == FAILURE) { return; } -- cgit v1.2.3