Răsfoiți Sursa

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.
Paul Yang 7 ani în urmă
părinte
comite
7a23a2ea5e
1 a modificat fișierele cu 3 adăugiri și 3 ștergeri
  1. 3 3
      php/ext/google/protobuf/message.c

+ 3 - 3
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.
 // object. Here, we manually modify it to our message in such a case.
 PHP_METHOD(Message, __construct) {
 PHP_METHOD(Message, __construct) {
   // Init message with array
   // 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;
     return;
   }
   }