@@ -438,10 +438,17 @@ static void v8js_invoke_callback(const v8::FunctionCallbackInfo<v8::Value>& info
438
438
new_tpl = v8::Local<v8::FunctionTemplate>::New
439
439
(isolate, ctx->template_cache .at (ce->name ));
440
440
441
- result = new_tpl->GetFunction ()->NewInstance (argc, argv);
441
+ v8::MaybeLocal<v8::Object> maybeResult = new_tpl->GetFunction ()->NewInstance (isolate->GetEnteredContext (), argc, argv);
442
+
443
+ if (!maybeResult.IsEmpty ()) {
444
+ result = maybeResult.ToLocalChecked ();
445
+ } else {
446
+ result = V8JS_UNDEFINED;
447
+ }
442
448
} else {
443
449
result = cb->Call (self, argc, argv);
444
450
}
451
+
445
452
info.GetReturnValue ().Set (result);
446
453
}
447
454
/* }}} */
@@ -804,7 +811,7 @@ static void v8js_named_property_deleter(v8::Local<v8::String> property, const v8
804
811
805
812
806
813
807
- static v8::Local <v8::Object> v8js_wrap_object (v8::Isolate *isolate, zend_class_entry *ce, zval *value) /* {{{ */
814
+ static v8::MaybeLocal <v8::Object> v8js_wrap_object (v8::Isolate *isolate, zend_class_entry *ce, zval *value) /* {{{ */
808
815
{
809
816
v8js_ctx *ctx = (v8js_ctx *) isolate->GetData (0 );
810
817
v8::Local<v8::FunctionTemplate> new_tpl;
@@ -903,11 +910,11 @@ static v8::Local<v8::Object> v8js_wrap_object(v8::Isolate *isolate, zend_class_e
903
910
904
911
// Create v8 wrapper object
905
912
v8::Local<v8::Value> external = v8::External::New (isolate, Z_OBJ_P (value));
906
- v8::Local <v8::Object> newobj = new_tpl->GetFunction ()->NewInstance (1 , &external);
913
+ v8::MaybeLocal <v8::Object> newobj = new_tpl->GetFunction ()->NewInstance (isolate-> GetEnteredContext (), 1 , &external);
907
914
908
- if (ce == zend_ce_closure) {
915
+ if (ce == zend_ce_closure && !newobj. IsEmpty () ) {
909
916
// free uncached function template when object is freed
910
- ctx->weak_closures [persist_tpl_].Reset (isolate, newobj);
917
+ ctx->weak_closures [persist_tpl_].Reset (isolate, newobj. ToLocalChecked () );
911
918
ctx->weak_closures [persist_tpl_].SetWeak (persist_tpl_, v8js_weak_closure_callback, v8::WeakCallbackType::kParameter );
912
919
}
913
920
@@ -1025,15 +1032,19 @@ v8::Local<v8::Value> v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate) /* {{
1025
1032
1026
1033
/* If it's a PHP object, wrap it */
1027
1034
if (ce) {
1028
- v8::Local<v8::Value> wrapped_object = v8js_wrap_object (isolate, ce, value);
1035
+ v8::MaybeLocal<v8::Object> wrapped_object = v8js_wrap_object (isolate, ce, value);
1036
+
1037
+ if (wrapped_object.IsEmpty ()) {
1038
+ return V8JS_UNDEFINED;
1039
+ }
1029
1040
1030
1041
if (ce == zend_ce_generator) {
1031
1042
/* Wrap PHP Generator object in a wrapper function that provides
1032
1043
* ES6 style behaviour. */
1033
- wrapped_object = v8js_wrap_generator (isolate, wrapped_object);
1044
+ return v8js_wrap_generator (isolate, wrapped_object. ToLocalChecked () );
1034
1045
}
1035
1046
1036
- return wrapped_object;
1047
+ return wrapped_object. ToLocalChecked () ;
1037
1048
}
1038
1049
1039
1050
/* Associative PHP arrays cannot be wrapped to JS arrays, convert them to
0 commit comments