0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 09:21:52 +00:00

Handle Z_TYPE == IS_REFERENCE well, fixes #246

This commit is contained in:
Stefan Siegl 2016-08-11 18:54:38 +02:00
parent 4161008417
commit 8126fc4928
2 changed files with 28 additions and 3 deletions

18
tests/issue_246_001.phpt Normal file
View File

@ -0,0 +1,18 @@
--TEST--
Test V8::executeString() : Handle Z_TYPE == IS_REFERENCE (issue #246)
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
$v8 = new V8Js();
$array = ['lorem' => 'ipsum'];
array_walk_recursive($array, function (&$item) {});
$v8->some_array = $array;
$v8->executeString('var_dump(PHP.some_array.lorem);');
?>
===EOF===
--EXPECT--
string(5) "ipsum"
===EOF===

View File

@ -104,11 +104,16 @@ v8::Handle<v8::Value> zval_to_v8js(zval *value, v8::Isolate *isolate TSRMLS_DC)
long v;
zend_class_entry *ce;
if(Z_TYPE_P(value) == IS_INDIRECT)
value = Z_INDIRECT_P(value);
switch (Z_TYPE_P(value))
{
case IS_INDIRECT:
jsValue = zval_to_v8js(Z_INDIRECT_P(value), isolate);
break;
case IS_REFERENCE:
jsValue = zval_to_v8js(Z_REFVAL_P(value), isolate);
break;
case IS_ARRAY:
jsValue = v8js_hash_to_jsarr(value, isolate TSRMLS_CC);
break;
@ -163,8 +168,10 @@ v8::Handle<v8::Value> zval_to_v8js(zval *value, v8::Isolate *isolate TSRMLS_DC)
case IS_UNDEF:
default:
/* undefined -> return v8::Value left empty */
jsValue = v8::Undefined(isolate);
break;
}
return jsValue;
}
/* }}} */