Skip to content

Commit 4bfe2ef

Browse files
committed
rename to setExceptionFilter
1 parent abb8b6d commit 4bfe2ef

9 files changed

+35
-35
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class V8Js
110110
* The factory function will receive the PHP Exception instance that has not been caught and is
111111
* due to be forwarded to JS.
112112
*/
113-
public function setExceptionProxyFactory(callable $factory)
113+
public function setExceptionFilter(callable $factory)
114114
{}
115115

116116
/**
@@ -413,5 +413,5 @@ via `getPrevious` method.
413413

414414
Consider that the JS code has access to methods like `getTrace` on the exception
415415
object. This might be unwanted behaviour, if you execute untrusted code.
416-
Using `setExceptionProxyFactory` method a callable can be provided, that converts
416+
Using `setExceptionFilter` method a callable can be provided, that converts
417417
the PHP exception to not expose unwanted information.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Test V8::setExceptionProxyFactory() : String conversion
2+
Test V8::setExceptionFilter() : String conversion
33
--SKIPIF--
44
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
55
--FILE--
@@ -12,8 +12,8 @@ class myv8 extends V8Js
1212
}
1313

1414
$v8 = new myv8();
15-
$v8->setExceptionProxyFactory(function (Throwable $ex) {
16-
echo "exception proxy factory called.\n";
15+
$v8->setExceptionFilter(function (Throwable $ex) {
16+
echo "exception filter called.\n";
1717
return $ex->getMessage();
1818
});
1919

@@ -29,7 +29,7 @@ $v8->executeString('
2929
?>
3030
===EOF===
3131
--EXPECT--
32-
exception proxy factory called.
32+
exception filter called.
3333
string(6) "string"
3434
string(4) "Oops"
3535
===EOF===
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Test V8::setExceptionProxyFactory() : Proxy handling on exception in setModuleLoader
2+
Test V8::setExceptionFilter() : Filter handling on exception in setModuleLoader
33
--SKIPIF--
44
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
55
--FILE--
@@ -10,8 +10,8 @@ $v8->setModuleLoader(function ($path) {
1010
throw new Error('moep');
1111
});
1212

13-
$v8->setExceptionProxyFactory(function (Throwable $ex) {
14-
echo "exception proxy factory called.\n";
13+
$v8->setExceptionFilter(function (Throwable $ex) {
14+
echo "exception filter called.\n";
1515
return $ex->getMessage();
1616
});
1717

@@ -26,7 +26,7 @@ $v8->executeString('
2626
?>
2727
===EOF===
2828
--EXPECT--
29-
exception proxy factory called.
29+
exception filter called.
3030
string(4) "moep"
3131
===EOF===
3232

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Test V8::setExceptionProxyFactory() : Proxy handling on exception in setModuleNormaliser
2+
Test V8::setExceptionFilter() : Filter handling on exception in setModuleNormaliser
33
--SKIPIF--
44
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
55
--FILE--
@@ -13,8 +13,8 @@ $v8->setModuleLoader(function ($path) {
1313
throw new Error('moep');
1414
});
1515

16-
$v8->setExceptionProxyFactory(function (Throwable $ex) {
17-
echo "exception proxy factory called.\n";
16+
$v8->setExceptionFilter(function (Throwable $ex) {
17+
echo "exception filter called.\n";
1818
return $ex->getMessage();
1919
});
2020

@@ -29,6 +29,6 @@ $v8->executeString('
2929
?>
3030
===EOF===
3131
--EXPECT--
32-
exception proxy factory called.
32+
exception filter called.
3333
string(5) "blarg"
3434
===EOF===
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Test V8::setExceptionProxyFactory() : Proxy handling on exception in factory
2+
Test V8::setExceptionFilter() : Filter handling on exception in factory
33
--SKIPIF--
44
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
55
--FILE--
@@ -12,7 +12,7 @@ class myv8 extends V8Js
1212
}
1313

1414
$v8 = new myv8();
15-
$v8->setExceptionProxyFactory(function (Throwable $ex) {
15+
$v8->setExceptionFilter(function (Throwable $ex) {
1616
throw new Exception('moep');
1717
});
1818

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Test V8::setExceptionProxyFactory() : Simple test
2+
Test V8::setExceptionFilter() : Simple test
33
--SKIPIF--
44
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
55
--FILE--
@@ -11,11 +11,11 @@ class myv8 extends V8Js
1111
}
1212
}
1313

14-
class ExceptionProxy {
14+
class ExceptionFilter {
1515
private $ex;
1616

1717
public function __construct(Throwable $ex) {
18-
echo "ExceptionProxy::__construct called!\n";
18+
echo "ExceptionFilter::__construct called!\n";
1919
var_dump($ex->getMessage());
2020

2121
$this->ex = $ex;
@@ -28,25 +28,25 @@ class ExceptionProxy {
2828
}
2929

3030
$v8 = new myv8();
31-
$v8->setExceptionProxyFactory(function (Throwable $ex) {
32-
echo "exception proxy factory called.\n";
33-
return new ExceptionProxy($ex);
31+
$v8->setExceptionFilter(function (Throwable $ex) {
32+
echo "exception filter called.\n";
33+
return new ExceptionFilter($ex);
3434
});
3535

3636
$v8->executeString('
3737
try {
3838
PHP.throwException("Oops");
3939
}
4040
catch (e) {
41-
var_dump(e.getMessage()); // calls ExceptionProxy::getMessage
41+
var_dump(e.getMessage()); // calls ExceptionFilter::getMessage
4242
var_dump(typeof e.getTrace);
4343
}
4444
', null, V8Js::FLAG_PROPAGATE_PHP_EXCEPTIONS);
4545
?>
4646
===EOF===
4747
--EXPECT--
48-
exception proxy factory called.
49-
ExceptionProxy::__construct called!
48+
exception filter called.
49+
ExceptionFilter::__construct called!
5050
string(4) "Oops"
5151
getMessage called
5252
string(4) "Oops"

v8js_class.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static void v8js_free_storage(zend_object *object) /* {{{ */
9292
zval_ptr_dtor(&c->pending_exception);
9393
zval_ptr_dtor(&c->module_normaliser);
9494
zval_ptr_dtor(&c->module_loader);
95-
zval_ptr_dtor(&c->exception_proxy_factory);
95+
zval_ptr_dtor(&c->exception_filter);
9696

9797
/* Delete PHP global object from JavaScript */
9898
if (!c->context.IsEmpty()) {
@@ -401,7 +401,7 @@ static PHP_METHOD(V8Js, __construct)
401401

402402
ZVAL_NULL(&c->module_normaliser);
403403
ZVAL_NULL(&c->module_loader);
404-
ZVAL_NULL(&c->exception_proxy_factory);
404+
ZVAL_NULL(&c->exception_filter);
405405

406406
/* Include extensions used by this context */
407407
/* Note: Extensions registered with auto_enable do not need to be added separately like this. */
@@ -882,9 +882,9 @@ static PHP_METHOD(V8Js, setModuleLoader)
882882
}
883883
/* }}} */
884884

885-
/* {{{ proto void V8Js::setExceptionProxyFactory(callable factory)
885+
/* {{{ proto void V8Js::setExceptionFilter(callable factory)
886886
*/
887-
static PHP_METHOD(V8Js, setExceptionProxyFactory)
887+
static PHP_METHOD(V8Js, setExceptionFilter)
888888
{
889889
zval *callable;
890890

@@ -893,7 +893,7 @@ static PHP_METHOD(V8Js, setExceptionProxyFactory)
893893
}
894894

895895
v8js_ctx *c = Z_V8JS_CTX_OBJ_P(getThis());
896-
ZVAL_COPY(&c->exception_proxy_factory, callable);
896+
ZVAL_COPY(&c->exception_filter, callable);
897897
}
898898
/* }}} */
899899

@@ -1271,7 +1271,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_v8js_setmoduleloader, 0, 0, 1)
12711271
ZEND_ARG_INFO(0, callable)
12721272
ZEND_END_ARG_INFO()
12731273

1274-
ZEND_BEGIN_ARG_INFO_EX(arginfo_v8js_setexceptionproxyfactory, 0, 0, 1)
1274+
ZEND_BEGIN_ARG_INFO_EX(arginfo_v8js_setexceptionfilter, 0, 0, 1)
12751275
ZEND_ARG_INFO(0, callable)
12761276
ZEND_END_ARG_INFO()
12771277

@@ -1314,7 +1314,7 @@ const zend_function_entry v8js_methods[] = { /* {{{ */
13141314
PHP_ME(V8Js, clearPendingException, arginfo_v8js_clearpendingexception, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
13151315
PHP_ME(V8Js, setModuleNormaliser, arginfo_v8js_setmodulenormaliser, ZEND_ACC_PUBLIC)
13161316
PHP_ME(V8Js, setModuleLoader, arginfo_v8js_setmoduleloader, ZEND_ACC_PUBLIC)
1317-
PHP_ME(V8Js, setExceptionProxyFactory, arginfo_v8js_setexceptionproxyfactory, ZEND_ACC_PUBLIC)
1317+
PHP_ME(V8Js, setExceptionFilter, arginfo_v8js_setexceptionfilter, ZEND_ACC_PUBLIC)
13181318
PHP_ME(V8Js, setTimeLimit, arginfo_v8js_settimelimit, ZEND_ACC_PUBLIC)
13191319
PHP_ME(V8Js, setMemoryLimit, arginfo_v8js_setmemorylimit, ZEND_ACC_PUBLIC)
13201320
PHP_ME(V8Js, setAverageObjectSize, arginfo_v8js_setaverageobjectsize, ZEND_ACC_PUBLIC)

v8js_class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct v8js_ctx {
5555

5656
zval module_normaliser;
5757
zval module_loader;
58-
zval exception_proxy_factory;
58+
zval exception_filter;
5959

6060
std::vector<char *> modules_stack;
6161
std::map<char *, v8js_persistent_value_t, cmp_str> modules_loaded;

v8js_object_export.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ v8::Local<v8::Value> v8js_propagate_exception(v8js_ctx *ctx) /* {{{ */
4545

4646
zval tmp_zv;
4747

48-
if (Z_TYPE(ctx->exception_proxy_factory) != IS_NULL) {
48+
if (Z_TYPE(ctx->exception_filter) != IS_NULL) {
4949
zval params[1];
5050
ZVAL_OBJ(&params[0], EG(exception));
5151
Z_ADDREF_P(&params[0]);
5252
zend_clear_exception();
53-
call_user_function(EG(function_table), NULL, &ctx->exception_proxy_factory, &tmp_zv, 1, params);
53+
call_user_function(EG(function_table), NULL, &ctx->exception_filter, &tmp_zv, 1, params);
5454
zval_ptr_dtor(&params[0]);
5555

5656
if(EG(exception)) {

0 commit comments

Comments
 (0)