com php-src: Convert fatal errors into EngineException: Zend/zend_API.c Zend/zend_exceptions.c Zend/zend_ interfaces.c Zend/zend_objects.c
ext/standard/tests/g eneral_functions/010.phpt
| From: | Dmitry Stogov | Date: | Thu, 02 Apr 2015 11:19:52 +0000 |
| Subject: | com php-src: Convert fatal errors into EngineException: Zend/zend_API.c Zend/zend_exceptions.c Zend/zend_ interfaces.c Zend/zend_objects.c ext/standard/tests/g eneral_functions/010.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-86051@lists.php.net to get a copy of this message | ||
Commit: ad863c1740fb5719efa3a3fb3a796afd40b1a50f
Author: Dmitry Stogov <dmitry@zend.com> Thu, 2 Apr 2015 14:19:52 +0300
Parents: bf259db82e000fcf05135245551348b5dc5cb489
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ad863c1740fb5719efa3a3fb3a796afd40b1a50f
Log:
Convert fatal errors into EngineException
Changed paths:
M Zend/zend_API.c
M Zend/zend_exceptions.c
M Zend/zend_interfaces.c
M Zend/zend_objects.c
M ext/standard/tests/general_functions/010.phpt
Diff:
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index bc7c0ff..310d9fb 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -3119,7 +3119,7 @@ get_function_via_handler:
verb = "should not";
} else {
/* An internal function assumes $this is present and won't check that. So PHP would crash
by allowing the call. */
- severity = E_ERROR; //TODO: add E_EXCEPTION???
+ severity = E_EXCEPTION | E_ERROR;
verb = "cannot";
}
if ((check_flags & IS_CALLABLE_CHECK_IS_STATIC) != 0) {
@@ -3127,7 +3127,7 @@ get_function_via_handler:
}
if (error) {
zend_spprintf(error, 0, "non-static method %s::%s() %s be called statically",
fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val,
verb);
- if (severity == E_ERROR) {
+ if (severity != E_DEPRECATED) {
retval = 0;
}
} else if (retval) {
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index a139c62..6eccc89 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -48,7 +48,7 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
}
ZVAL_OBJ(&tmp, add_previous);
if (!instanceof_function(Z_OBJCE(tmp), base_exception_ce)) {
- zend_error_noreturn(E_ERROR, "Cannot set non exception as previous exception");
+ zend_error_noreturn(E_CORE_ERROR, "Cannot set non exception as previous exception");
return;
}
ZVAL_OBJ(&zv, exception);
@@ -116,7 +116,7 @@ ZEND_API void zend_throw_exception_internal(zval *exception) /* {{{ */
if(EG(exception)) {
zend_exception_error(EG(exception), E_ERROR);
}
- zend_error_noreturn(E_ERROR, "Exception thrown without a stack frame");
+ zend_error_noreturn(E_CORE_ERROR, "Exception thrown without a stack frame");
}
if (zend_throw_exception_hook) {
@@ -215,7 +215,8 @@ ZEND_METHOD(exception, __construct)
int argc = ZEND_NUM_ARGS();
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc, "|SlO!", &message,
&code, &previous, base_exception_ce) == FAILURE) {
- zend_error_noreturn(E_ERROR, "Wrong parameters for Exception([string $exception [, long
$code [, Exception $previous = NULL]]])");
+ zend_error(E_EXCEPTION | E_ERROR, "Wrong parameters for Exception([string $exception [, long
$code [, Exception $previous = NULL]]])");
+ return;
}
object = getThis();
@@ -245,7 +246,8 @@ ZEND_METHOD(error_exception, __construct)
size_t message_len, filename_len;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc, "|sllslO!", &message,
&message_len, &code, &severity, &filename, &filename_len, &lineno,
&previous, base_exception_ce) == FAILURE) {
- zend_error_noreturn(E_ERROR, "Wrong parameters for ErrorException([string $exception [, long
$code, [ long $severity, [ string $filename, [ long $lineno [, Exception $previous =
NULL]]]]]])");
+ zend_error(E_EXCEPTION | E_ERROR, "Wrong parameters for ErrorException([string $exception [,
long $code, [ long $severity, [ string $filename, [ long $lineno [, Exception $previous =
NULL]]]]]])");
+ return;
}
object = getThis();
@@ -972,13 +974,14 @@ ZEND_API void zend_throw_exception_object(zval *exception) /* {{{ */
zend_class_entry *exception_ce;
if (exception == NULL || Z_TYPE_P(exception) != IS_OBJECT) {
- zend_error_noreturn(E_ERROR, "Need to supply an object when throwing an exception");
+ zend_error_noreturn(E_CORE_ERROR, "Need to supply an object when throwing an
exception");
}
exception_ce = Z_OBJCE_P(exception);
if (!exception_ce || !instanceof_function(exception_ce, base_exception_ce)) {
- zend_error_noreturn(E_ERROR, "Exceptions must be valid objects derived from the Exception
base class");
+ zend_error(E_EXCEPTION | E_ERROR, "Exceptions must be valid objects derived from the
Exception base class");
+ return;
}
zend_throw_exception_internal(exception);
}
diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c
index 93c0209..5cb7024 100644
--- a/Zend/zend_interfaces.c
+++ b/Zend/zend_interfaces.c
@@ -259,7 +259,8 @@ static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zva
zend_user_iterator *iterator;
if (by_ref) {
- zend_error_noreturn(E_ERROR, "An iterator cannot be used with foreach by reference");
+ zend_error(E_EXCEPTION | E_ERROR, "An iterator cannot be used with foreach by
reference");
+ return NULL;
}
iterator = emalloc(sizeof(zend_user_iterator));
diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c
index ffdd9df..eda8f0c 100644
--- a/Zend/zend_objects.c
+++ b/Zend/zend_objects.c
@@ -117,7 +117,7 @@ ZEND_API void zend_objects_destroy_object(zend_object *object)
old_exception = NULL;
if (EG(exception)) {
if (EG(exception) == object) {
- zend_error_noreturn(E_ERROR, "Attempt to destruct pending exception");
+ zend_error_noreturn(E_CORE_ERROR, "Attempt to destruct pending exception");
} else {
old_exception = EG(exception);
EG(exception) = NULL;
diff --git a/ext/standard/tests/general_functions/010.phpt
b/ext/standard/tests/general_functions/010.phpt
index f576c7e..a4802b0 100644
--- a/ext/standard/tests/general_functions/010.phpt
+++ b/ext/standard/tests/general_functions/010.phpt
@@ -11,9 +11,16 @@ class test {
}
}
-var_dump(register_shutdown_function(array("test","__call")));
+try {
+ var_dump(register_shutdown_function(array("test","__call")));
+} catch (EngineException $e) {
+ echo "\nException: " . $e->getMessage() . "\n";
+}
echo "Done\n";
?>
---EXPECTF--
+--EXPECTF--
+Exception: Non-static method test::__call() cannot be called statically
+Done
+
Fatal error: Non-static method test::__call() cannot be called statically in %s on line %d