Skip to content

Commit 296b907

Browse files
committed
fix exception back-propagation on PHP7
1 parent 5cba44c commit 296b907

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tests/php_exceptions_005.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ catch(V8JsScriptException $e) {
3434
--EXPECTF--
3535
after getException
3636
Got V8JsScriptException
37-
string(%d) "php_exceptions_005:3: exception 'Exception' with message 'Test-Exception' in %s
37+
string(%d) "php_exceptions_005:3: Exception: Test-Exception in %s
3838
Stack trace:
3939
#0 [internal function]: Foo->getException()
4040
#1 %s: V8Js->executeString('var ex = PHP.fo...', 'php_exceptions_...')

v8js_exceptions.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ void v8js_create_script_exception(zval *return_value, v8::Isolate *isolate, v8::
8888

8989
if(!php_ref.IsEmpty()) {
9090
assert(php_ref->IsExternal());
91-
zval *php_exception = reinterpret_cast<zval *>(v8::External::Cast(*php_ref)->Value());
91+
zend_object *php_exception = reinterpret_cast<zend_object *>(v8::External::Cast(*php_ref)->Value());
9292

9393
zend_class_entry *exception_ce = zend_exception_get_default(TSRMLS_C);
94-
if (Z_TYPE_P(php_exception) == IS_OBJECT && instanceof_function(Z_OBJCE_P(php_exception), exception_ce TSRMLS_CC)) {
95-
Z_ADDREF_P(php_exception);
96-
zend_exception_set_previous(Z_OBJ_P(return_value), Z_OBJ_P(php_exception));
94+
if (instanceof_function(php_exception->ce, exception_ce TSRMLS_CC)) {
95+
++GC_REFCOUNT(php_exception);
96+
zend_exception_set_previous(Z_OBJ_P(return_value), php_exception);
9797
}
9898
}
9999
}

0 commit comments

Comments
 (0)