com php-src: Convert fatal errors into EngineExceptions: Zend/tests/exception_017.phpt Zend/zend_API.c Zend/zend_execute_API.c Zend/zend_operators.c
| From: | Dmitry Stogov | Date: | Wed, 01 Apr 2015 13:48:15 +0000 |
| Subject: | com php-src: Convert fatal errors into EngineExceptions: Zend/tests/exception_017.phpt Zend/zend_API.c Zend/zend_execute_API.c Zend/zend_operators.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-86024@lists.php.net to get a copy of this message | ||
Commit: 780a8123fe11ef255b264b18b3482cc1a0810d61
Author: Dmitry Stogov <dmitry@zend.com> Wed, 1 Apr 2015 16:48:15 +0300
Parents: 0cad725886dc620632f3aa413c1e944411465cd0
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=780a8123fe11ef255b264b18b3482cc1a0810d61
Log:
Convert fatal errors into EngineExceptions
Changed paths:
A Zend/tests/exception_017.phpt
M Zend/zend_API.c
M Zend/zend_execute_API.c
M Zend/zend_operators.c
Diff:
diff --git a/Zend/tests/exception_017.phpt b/Zend/tests/exception_017.phpt
new file mode 100644
index 0000000..9ce9ebd
--- /dev/null
+++ b/Zend/tests/exception_017.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Exceptions on improper usage of $this
+--FILE--
+<?php
+abstract class C {
+ abstract static function foo();
+}
+
+function foo(callable $x) {
+}
+
+try {
+ C::foo();
+} catch (EngineException $e) {
+ echo "\nException: " . $e->getMessage() . " in " , $e->getFile() .
" on line " . $e->getLine() . "\n";
+}
+
+try {
+ foo("C::foo");
+} catch (EngineException $e) {
+ echo "\n";
+ do {
+ echo "Exception: " . $e->getMessage() . "\n";
+ $e = $e->getPrevious();
+ } while ($e instanceof EngineException);
+}
+
+C::foo();
+?>
+--EXPECTF--
+Exception: Cannot call abstract method C::foo() in %sexception_017.php on line %d
+
+Exception: Argument 1 passed to foo() must be callable, string given, called in %sexception_017.php
on line %d
+Exception: Cannot call abstract method C::foo()
+
+Fatal error: Cannot call abstract method C::foo() in %sexception_017.php on line %d
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 37de396..d10587a 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -3092,7 +3092,8 @@ get_function_via_handler:
zend_spprintf(error, 0, "cannot call abstract method %s::%s()",
fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val);
retval = 0;
} else {
- zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()",
fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val);
+ zend_error(E_EXCEPTION | E_ERROR, "Cannot call abstract method %s::%s()",
fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val);
+ return 0;
}
} else if (!fcc->object && !(fcc->function_handler->common.fn_flags &
ZEND_ACC_STATIC)) {
int severity;
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index dcf972b..fc212db 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -774,7 +774,8 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
if (func->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) {
if (func->common.fn_flags & ZEND_ACC_ABSTRACT) {
- zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()",
func->common.scope->name->val, func->common.function_name->val);
+ zend_error(E_EXCEPTION | E_ERROR, "Cannot call abstract method %s::%s()",
func->common.scope->name->val, func->common.function_name->val);
+ return FAILURE;
}
if (func->common.fn_flags & ZEND_ACC_DEPRECATED) {
zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
@@ -919,7 +920,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
fci->object->handlers->call_method(func->common.function_name, fci->object, call,
fci->retval);
EG(current_execute_data) = call->prev_execute_data;
} else {
- zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object");
+ zend_error(E_EXCEPTION | E_ERROR, "Cannot call overloaded function for non-object");
}
zend_vm_stack_free_args(call);
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index daa3ada..7a06fdb 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -1545,7 +1545,9 @@ ZEND_API int ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2)
/
zend_string *result_str;
if (op1_len > SIZE_MAX - op2_len) {
- zend_error_noreturn(E_ERROR, "String size overflow");
+ zend_error(E_EXCEPTION | E_ERROR, "String size overflow");
+ ZVAL_FALSE(result);
+ return;
}
if (result == op1 && Z_REFCOUNTED_P(result)) {