0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 14:01:53 +00:00

Make php_v8js_write_property export only public properties

Before a property would have been exported, even if a derived
class declared it either private or protected.
This commit is contained in:
Stefan Siegl 2013-10-19 02:22:13 +02:00
parent b888cfce0d
commit 257233be51

14
v8js.cc
View File

@ -1296,12 +1296,16 @@ static void php_v8js_write_property(zval *object, zval *member, zval *value ZEND
{
V8JS_BEGIN_CTX(c, object)
/* Global PHP JS object */
v8::Local<v8::String> object_name_js = v8::Local<v8::String>::New(c->isolate, c->object_name);
v8::Local<v8::Object> jsobj = V8JS_GLOBAL->Get(object_name_js)->ToObject();
/* Check whether member is public, if so, export to V8. */
zend_property_info *property_info = zend_get_property_info(c->std.ce, member, 1 TSRMLS_CC);
if(property_info->flags & ZEND_ACC_PUBLIC) {
/* Global PHP JS object */
v8::Local<v8::String> object_name_js = v8::Local<v8::String>::New(c->isolate, c->object_name);
v8::Local<v8::Object> jsobj = V8JS_GLOBAL->Get(object_name_js)->ToObject();
/* Write value to PHP JS object */
jsobj->ForceSet(V8JS_SYML(Z_STRVAL_P(member), Z_STRLEN_P(member)), zval_to_v8js(value, c->isolate TSRMLS_CC), v8::ReadOnly);
/* Write value to PHP JS object */
jsobj->ForceSet(V8JS_SYML(Z_STRVAL_P(member), Z_STRLEN_P(member)), zval_to_v8js(value, c->isolate TSRMLS_CC), v8::ReadOnly);
}
/* Write value to PHP object */
std_object_handlers.write_property(object, member, value ZEND_HASH_KEY_CC TSRMLS_CC);