Browse Source

Merge pull request #331 from stesie/mark-pending-exceptions-deprecated

Mark pending exceptions deprecated
Stefan Siegl 7 years ago
parent
commit
3afd98ba3a

+ 13 - 0
tests/exception_clearing.phpt

@@ -21,8 +21,17 @@ var_dump($v8->getPendingException());
 ?>
 ?>
 ===EOF===
 ===EOF===
 --EXPECTF--
 --EXPECTF--
+Deprecated: V8Js::__construct(): Disabling exception reporting is deprecated, $report_uncaught_exceptions != true in %s%eexception_clearing.php on line 3
+
+Deprecated: Function V8Js::getPendingException() is deprecated in %s%eexception_clearing.php on line 5
 NULL
 NULL
+
+Deprecated: Function V8Js::clearPendingException() is deprecated in %s%eexception_clearing.php on line 7
+
+Deprecated: Function V8Js::getPendingException() is deprecated in %s%eexception_clearing.php on line 8
 NULL
 NULL
+
+Deprecated: Function V8Js::getPendingException() is deprecated in %s%eexception_clearing.php on line 11
 object(V8JsScriptException)#%d (13) {
 object(V8JsScriptException)#%d (13) {
   ["message":protected]=>
   ["message":protected]=>
   string(49) "throw_0:1: ReferenceError: fooobar is not defined"
   string(49) "throw_0:1: ReferenceError: fooobar is not defined"
@@ -73,5 +82,9 @@ object(V8JsScriptException)#%d (13) {
   string(57) "ReferenceError: fooobar is not defined
   string(57) "ReferenceError: fooobar is not defined
     at throw_0:1:1"
     at throw_0:1:1"
 }
 }
+
+Deprecated: Function V8Js::clearPendingException() is deprecated in %s%eexception_clearing.php on line 13
+
+Deprecated: Function V8Js::getPendingException() is deprecated in %s%eexception_clearing.php on line 14
 NULL
 NULL
 ===EOF===
 ===EOF===

+ 3 - 0
tests/exception_propagation_2.phpt

@@ -38,6 +38,9 @@ try {
 ?>
 ?>
 ===EOF===
 ===EOF===
 --EXPECTF--
 --EXPECTF--
+Deprecated: V8Js::__construct(): Disabling exception reporting is deprecated, $report_uncaught_exceptions != true in %s%eexception_propagation_2.php on line 8
+
+Deprecated: Function V8Js::getPendingException() is deprecated in %s%eexception_propagation_2.php on line 11
 object(V8JsScriptException)#%d (13) {
 object(V8JsScriptException)#%d (13) {
   ["message":protected]=>
   ["message":protected]=>
   string(49) "throw_0:1: ReferenceError: fooobar is not defined"
   string(49) "throw_0:1: ReferenceError: fooobar is not defined"

+ 2 - 1
tests/exception_propagation_3.phpt

@@ -31,7 +31,8 @@ try {
 }
 }
 ?>
 ?>
 ===EOF===
 ===EOF===
---EXPECT--
+--EXPECTF--
+Deprecated: V8Js::__construct(): Disabling exception reporting is deprecated, $report_uncaught_exceptions != true in %s%eexception_propagation_3.php on line 8
 SyntaxError caught in JS!
 SyntaxError caught in JS!
 To Bar!
 To Bar!
 Error caught via PHP callback!
 Error caught via PHP callback!

+ 6 - 2
v8js_class.cc

@@ -357,6 +357,10 @@ static PHP_METHOD(V8Js, __construct)
 	ZVAL_NULL(&c->pending_exception);
 	ZVAL_NULL(&c->pending_exception);
 	c->in_execution = 0;
 	c->in_execution = 0;
 
 
+	if (report_uncaught != 1) {
+		php_error_docref(NULL, E_DEPRECATED, "Disabling exception reporting is deprecated, $report_uncaught_exceptions != true");
+	}
+
 	new (&c->create_params) v8::Isolate::CreateParams();
 	new (&c->create_params) v8::Isolate::CreateParams();
 
 
 #ifdef USE_INTERNAL_ALLOCATOR
 #ifdef USE_INTERNAL_ALLOCATOR
@@ -1265,8 +1269,8 @@ const zend_function_entry v8js_methods[] = { /* {{{ */
 	PHP_ME(V8Js,	compileString,			arginfo_v8js_compilestring,			ZEND_ACC_PUBLIC)
 	PHP_ME(V8Js,	compileString,			arginfo_v8js_compilestring,			ZEND_ACC_PUBLIC)
 	PHP_ME(V8Js,    executeScript,			arginfo_v8js_executescript,			ZEND_ACC_PUBLIC)
 	PHP_ME(V8Js,    executeScript,			arginfo_v8js_executescript,			ZEND_ACC_PUBLIC)
 	PHP_ME(V8Js,    checkString,			arginfo_v8js_checkstring,			ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
 	PHP_ME(V8Js,    checkString,			arginfo_v8js_checkstring,			ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
-	PHP_ME(V8Js,	getPendingException,	arginfo_v8js_getpendingexception,	ZEND_ACC_PUBLIC)
-	PHP_ME(V8Js,	clearPendingException,	arginfo_v8js_clearpendingexception,	ZEND_ACC_PUBLIC)
+	PHP_ME(V8Js,	getPendingException,	arginfo_v8js_getpendingexception,	ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
+	PHP_ME(V8Js,	clearPendingException,	arginfo_v8js_clearpendingexception,	ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
 	PHP_ME(V8Js,	setModuleNormaliser,	arginfo_v8js_setmodulenormaliser,	ZEND_ACC_PUBLIC)
 	PHP_ME(V8Js,	setModuleNormaliser,	arginfo_v8js_setmodulenormaliser,	ZEND_ACC_PUBLIC)
 	PHP_ME(V8Js,	setModuleLoader,		arginfo_v8js_setmoduleloader,		ZEND_ACC_PUBLIC)
 	PHP_ME(V8Js,	setModuleLoader,		arginfo_v8js_setmoduleloader,		ZEND_ACC_PUBLIC)
 	PHP_ME(V8Js,	setTimeLimit,			arginfo_v8js_settimelimit,			ZEND_ACC_PUBLIC)
 	PHP_ME(V8Js,	setTimeLimit,			arginfo_v8js_settimelimit,			ZEND_ACC_PUBLIC)