Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/issue_246_001.phpt
Original file line number Diff line number Diff line change
@@ -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===
13 changes: 10 additions & 3 deletions v8js_convert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
/* }}} */
Expand Down