Skip to content

Commit 53995ac

Browse files
author
Stefan Siegl
committed
Make FLAG_FORCE_ARRAY not affect V8Function objects, #closes 160
1 parent de0931a commit 53995ac

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

tests/issue_160_basic.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Test V8::executeString() : Issue #160 V8Function affected by V8Js::FLAG_FORCE_ARRAY
3+
--SKIPIF--
4+
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
$v8 = new V8Js();
8+
9+
$JS = <<<EOT
10+
(function(foo) { print(foo); });
11+
EOT;
12+
13+
$func = $v8->executeString($JS, 'test', V8Js::FLAG_FORCE_ARRAY);
14+
15+
var_dump($func);
16+
$func("Test-Foo Func Call\n");
17+
?>
18+
===EOF===
19+
--EXPECTF--
20+
object(V8Function)#%d (0) {
21+
}
22+
Test-Foo Func Call
23+
===EOF===

v8js_convert.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ int v8js_to_zval(v8::Handle<v8::Value> jsValue, zval *return_value, int flags, v
244244
RETVAL_ZVAL(object, 1, 0);
245245
return SUCCESS;
246246
}
247-
if ((flags & V8JS_FLAG_FORCE_ARRAY) || jsValue->IsArray()) {
247+
if ((flags & V8JS_FLAG_FORCE_ARRAY && !jsValue->IsFunction()) || jsValue->IsArray()) {
248248
array_init(return_value);
249249
return v8js_get_properties_hash(jsValue, Z_ARRVAL_P(return_value), flags, isolate TSRMLS_CC);
250250
} else {

0 commit comments

Comments
 (0)