mirror of
https://github.com/phpv8/v8js.git
synced 2024-12-22 15:11:53 +00:00
Merge remote-tracking branch 'stesie/remove-compat-exceptions' into php7
This commit is contained in:
commit
f1e2c36a0a
@ -414,10 +414,3 @@ objects obeying the above rules and re-thrown in JavaScript context. If they
|
||||
are not caught by JavaScript code the execution stops and a
|
||||
`V8JsScriptException` is thrown, which has the original PHP exception accessible
|
||||
via `getPrevious` method.
|
||||
|
||||
V8Js versions 0.2.4 and before did not stop JS code execution on PHP exceptions,
|
||||
but silently ignored them (even so succeeding PHP calls from within the same piece
|
||||
of JS code were not executed by the PHP engine). This behaviour is considered as
|
||||
a bug and hence was fixed with 0.2.5 release. Nevertheless there is a
|
||||
compatibility php.ini switch (`v8js.compat_php_exceptions`) which turns previous
|
||||
behaviour back on.
|
||||
|
@ -113,7 +113,6 @@ ZEND_BEGIN_MODULE_GLOBALS(v8js)
|
||||
/* Ini globals */
|
||||
bool use_date; /* Generate JS Date objects instead of PHP DateTime */
|
||||
bool use_array_access; /* Convert ArrayAccess, Countable objects to array-like objects */
|
||||
bool compat_php_exceptions; /* Don't stop JS execution on PHP exception */
|
||||
|
||||
// Timer thread globals
|
||||
std::deque<v8js_timer_ctx *> timer_stack;
|
||||
|
@ -1,33 +0,0 @@
|
||||
--TEST--
|
||||
Test V8::executeString() : Backwards compatibility for issue #156
|
||||
--SKIPIF--
|
||||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||
--INI--
|
||||
v8js.compat_php_exceptions = 1
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$v8 = new V8Js();
|
||||
|
||||
$v8->throwPHPException = function () {
|
||||
echo "throwing PHP exception now ...\n";
|
||||
throw new \Exception('foo');
|
||||
};
|
||||
|
||||
$JS = <<< EOT
|
||||
PHP.throwPHPException();
|
||||
print("... old behaviour was to not stop JS execution on PHP exceptions\\n");
|
||||
EOT;
|
||||
|
||||
try {
|
||||
$v8->executeString($JS, 'issue_156_001.js');
|
||||
} catch(Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
}
|
||||
?>
|
||||
===EOF===
|
||||
--EXPECT--
|
||||
throwing PHP exception now ...
|
||||
... old behaviour was to not stop JS execution on PHP exceptions
|
||||
string(3) "foo"
|
||||
===EOF===
|
@ -112,19 +112,11 @@ static ZEND_INI_MH(v8js_OnUpdateUseArrayAccess) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static ZEND_INI_MH(v8js_OnUpdateCompatExceptions) /* {{{ */
|
||||
{
|
||||
V8JSG(compat_php_exceptions) = v8js_ini_to_bool(new_value);
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_INI_BEGIN() /* {{{ */
|
||||
ZEND_INI_ENTRY("v8js.flags", NULL, ZEND_INI_ALL, v8js_OnUpdateV8Flags)
|
||||
ZEND_INI_ENTRY("v8js.icudtl_dat_path", NULL, ZEND_INI_ALL, v8js_OnUpdateIcudatPath)
|
||||
ZEND_INI_ENTRY("v8js.use_date", "0", ZEND_INI_ALL, v8js_OnUpdateUseDate)
|
||||
ZEND_INI_ENTRY("v8js.use_array_access", "0", ZEND_INI_ALL, v8js_OnUpdateUseArrayAccess)
|
||||
ZEND_INI_ENTRY("v8js.compat_php_exceptions", "0", ZEND_INI_ALL, v8js_OnUpdateCompatExceptions)
|
||||
ZEND_INI_END()
|
||||
/* }}} */
|
||||
|
||||
|
@ -162,7 +162,7 @@ failure:
|
||||
efree(fci.params);
|
||||
}
|
||||
|
||||
if(EG(exception) && !V8JSG(compat_php_exceptions)) {
|
||||
if(EG(exception)) {
|
||||
if(ctx->flags & V8JS_FLAG_PROPAGATE_PHP_EXCEPTIONS) {
|
||||
zval tmp_zv;
|
||||
ZVAL_OBJ(&tmp_zv, EG(exception));
|
||||
|
Loading…
Reference in New Issue
Block a user