diff options
author | Paul Yang <TeBoring@users.noreply.github.com> | 2018-05-10 10:52:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-10 10:52:39 -0700 |
commit | 7377d81ca44baf2e505c927a2e25b2f0e3596fed (patch) | |
tree | ccf8a107b26fa0babeae41a0a30017f063d2a4fa /php | |
parent | 5f7334f5f3c5015cdcaf21d456f0829486717b15 (diff) | |
download | protobuf-7377d81ca44baf2e505c927a2e25b2f0e3596fed.tar.gz protobuf-7377d81ca44baf2e505c927a2e25b2f0e3596fed.tar.bz2 protobuf-7377d81ca44baf2e505c927a2e25b2f0e3596fed.zip |
Throw error if user want to access message properties (#4603)
* Throw error if user want to access message properties
* Fix typo
Diffstat (limited to 'php')
-rw-r--r-- | php/ext/google/protobuf/message.c | 8 | ||||
-rwxr-xr-x | php/tests/test.sh | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index 4c68c391..c8f4d62b 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -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, diff --git a/php/tests/test.sh b/php/tests/test.sh index 2983fe99..6e70eb2a 100755 --- a/php/tests/test.sh +++ b/php/tests/test.sh @@ -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 |