Throw error if user want to access message properties (#4603)

* Throw error if user want to access message properties

* Fix typo
pull/4609/head
Paul Yang 7 years ago committed by GitHub
parent 5f7334f5f3
commit 7377d81ca4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      php/ext/google/protobuf/message.c
  2. 2
      php/tests/test.sh

@ -222,7 +222,13 @@ static zval* message_get_property_ptr_ptr(zval* object, zval* member, int type,
}
static HashTable* message_get_properties(zval* object TSRMLS_DC) {
return NULL;
// User cannot get property directly (e.g., $a = $m->a)
zend_error(E_USER_ERROR, "Cannot access private properties.");
#if PHP_MAJOR_VERSION < 7
return zend_std_get_properties(object TSRMLS_CC);
#else
return zend_std_get_properties(object);
#endif
}
static HashTable* message_get_gc(zval* object, CACHED_VALUE** table,

@ -21,7 +21,7 @@ do
echo "****************************"
echo "* $t"
echo "****************************"
# php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` --bootstrap autoload.php $t
php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` --bootstrap autoload.php $t
echo ""
done

Loading…
Cancel
Save