0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-09-19 15:25:19 +00:00

remove v8js.compat_php_exceptions

This commit is contained in:
Stefan Siegl 2017-11-26 11:48:52 +01:00
parent b8776318de
commit 302bf1d0ff
No known key found for this signature in database
GPG Key ID: 73942AF5642F3DDA
5 changed files with 1 additions and 50 deletions

View File

@ -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 are not caught by JavaScript code the execution stops and a
`V8JsScriptException` is thrown, which has the original PHP exception accessible `V8JsScriptException` is thrown, which has the original PHP exception accessible
via `getPrevious` method. 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.

View File

@ -113,7 +113,6 @@ ZEND_BEGIN_MODULE_GLOBALS(v8js)
/* Ini globals */ /* Ini globals */
bool use_date; /* Generate JS Date objects instead of PHP DateTime */ bool use_date; /* Generate JS Date objects instead of PHP DateTime */
bool use_array_access; /* Convert ArrayAccess, Countable objects to array-like objects */ 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 // Timer thread globals
std::deque<v8js_timer_ctx *> timer_stack; std::deque<v8js_timer_ctx *> timer_stack;

View File

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

View File

@ -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_BEGIN() /* {{{ */
ZEND_INI_ENTRY("v8js.flags", NULL, ZEND_INI_ALL, v8js_OnUpdateV8Flags) 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.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_date", "0", ZEND_INI_ALL, v8js_OnUpdateUseDate)
ZEND_INI_ENTRY("v8js.use_array_access", "0", ZEND_INI_ALL, v8js_OnUpdateUseArrayAccess) 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() ZEND_INI_END()
/* }}} */ /* }}} */

View File

@ -162,7 +162,7 @@ failure:
efree(fci.params); efree(fci.params);
} }
if(EG(exception) && !V8JSG(compat_php_exceptions)) { if(EG(exception)) {
if(ctx->flags & V8JS_FLAG_PROPAGATE_PHP_EXCEPTIONS) { if(ctx->flags & V8JS_FLAG_PROPAGATE_PHP_EXCEPTIONS) {
zval tmp_zv; zval tmp_zv;
ZVAL_OBJ(&tmp_zv, EG(exception)); ZVAL_OBJ(&tmp_zv, EG(exception));