ソースを参照

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

Stefan Siegl 10 年 前
コミット
3145ea0323
2 ファイル変更27 行追加0 行削除
  1. 25 0
      tests/regression_121.phpt
  2. 2 0
      v8js_convert.cc

+ 25 - 0
tests/regression_121.phpt

@@ -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===

+ 2 - 0
v8js_convert.cc

@@ -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;
 		}