0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-11-08 11:28:42 +00:00

Set hidden data also on already know weak objects, closes #121

This commit is contained in:
Stefan Siegl 2014-10-30 22:02:13 +00:00
parent a9d7dbda45
commit 3145ea0323
2 changed files with 27 additions and 0 deletions

25
tests/regression_121.phpt Normal file
View File

@ -0,0 +1,25 @@
--TEST--
Test V8::executeString() : Regression #121 Z_ADDREF_P
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$v8 = new V8Js();
$v8->blar = new stdClass();
$js = <<<EOT
PHP.blar.blub = {}
PHP.blar.blub['foo'] = 23;
PHP.blar.blub['bar'] = 5;
PHP.blar.blub['baz'] = 42;
print("Hello World!\\n");
EOT;
$v8->executeString($js);
?>
===EOF===
--EXPECT--
Hello World!
===EOF===

View File

@ -283,6 +283,8 @@ static void php_v8js_construct_callback(const v8::FunctionCallbackInfo<v8::Value
if(ctx->weak_objects.count(value)) {
// We already exported this object, hence no need to add another
// ref, v8 won't give us a second weak-object callback anyways.
newobj->SetAlignedPointerInInternalField(0, ext_tmpl->Value());
newobj->SetHiddenValue(V8JS_SYM(PHPJS_OBJECT_KEY), php_object);
return;
}