From d05926861b62c5e7e2ff901f39a7edcda191bf5e Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 31 Aug 2018 10:48:17 -0700 Subject: Fix well known type class not inheriting Message (#5095) * Fix well known type class not inheriting Message Previously, well known types only implement Message interface but not inhert it. Fix the problem by calling zend_do_inheritance * Add back commented tests --- php/ext/google/protobuf/protobuf.h | 5 +++-- php/tests/well_known_test.php | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'php') diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 9cb36dc2..a84feec6 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -138,7 +138,8 @@ INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \ LOWWERNAME##_methods); \ LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC); \ - LOWWERNAME##_type->create_object = message_create; + LOWWERNAME##_type->create_object = message_create; \ + zend_do_inheritance(LOWWERNAME##_type, message_type TSRMLS_CC); #define PHP_PROTO_INIT_SUBMSGCLASS_END \ } @@ -404,7 +405,7 @@ static inline int php_proto_zend_hash_get_current_data_ex(HashTable* ht, INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \ LOWWERNAME##_methods); \ LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC); \ - LOWWERNAME##_type->create_object = message_create; + zend_do_inheritance(LOWWERNAME##_type, message_type TSRMLS_CC); #define PHP_PROTO_INIT_SUBMSGCLASS_END \ } diff --git a/php/tests/well_known_test.php b/php/tests/well_known_test.php index 9f2661fa..6a788df2 100644 --- a/php/tests/well_known_test.php +++ b/php/tests/well_known_test.php @@ -42,6 +42,7 @@ class WellKnownTest extends TestBase { public function testEmpty() { $msg = new GPBEmpty(); + $this->assertTrue($msg instanceof \Google\Protobuf\Internal\Message); } public function testImportDescriptorProto() -- cgit v1.2.3