From: Derick Rethans Date: Thu, 15 Sep 2005 16:19:48 +0000 (+0000) Subject: - Add E_RECOVERABLE. X-Git-Tag: RELEASE_0_9_0~206 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f391bb0b350c4b91102314ec8920262fe72875a;p=php - Add E_RECOVERABLE. #- Thought I did this before already actually... --- diff --git a/Zend/tests/array_type_hint_001.phpt b/Zend/tests/array_type_hint_001.phpt index b110622aeb..def85b39bd 100755 --- a/Zend/tests/array_type_hint_001.phpt +++ b/Zend/tests/array_type_hint_001.phpt @@ -12,4 +12,4 @@ foo(123); --EXPECTF-- 3 -Fatal error: Argument 1 must be an array, called in %sarray_type_hint_001.php on line 7 and defined in %sarray_type_hint_001.php on line 2 +Catchable fatal error: Argument 1 must be an array, called in %sarray_type_hint_001.php on line 7 and defined in %sarray_type_hint_001.php on line 2 diff --git a/Zend/tests/bug33996.phpt b/Zend/tests/bug33996.phpt index 9b52f02a8f..a56bae1675 100755 --- a/Zend/tests/bug33996.phpt +++ b/Zend/tests/bug33996.phpt @@ -26,4 +26,4 @@ FooTest(new Foo()); --EXPECTF-- Warning: Missing argument 1 for NormalTest(), called in %sbug33996.php on line 17 and defined in %sbug33996.php on line 12 Hi! -Fatal error: Argument 1 must be an object of class Foo, called in %sbug33996.php on line 18 and defined in %sbug33996.php on line 7 +Catchable fatal error: Argument 1 must be an object of class Foo, called in %sbug33996.php on line 18 and defined in %sbug33996.php on line 7 diff --git a/Zend/zend.c b/Zend/zend.c index 4532e1e06c..8de73997a1 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -1672,6 +1672,7 @@ ZEND_API void zend_error(int type, const char *format, ...) case E_USER_ERROR: case E_USER_WARNING: case E_USER_NOTICE: + case E_RECOVERABLE_ERROR: if (zend_is_compiling(TSRMLS_C)) { error_filename = zend_get_compiled_filename(TSRMLS_C); error_lineno = zend_get_compiled_lineno(TSRMLS_C); diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index 79d8618220..5c4eab9442 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -94,6 +94,7 @@ int zend_startup_constants(TSRMLS_D) void zend_register_standard_constants(TSRMLS_D) { REGISTER_MAIN_LONG_CONSTANT("E_ERROR", E_ERROR, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_LONG_CONSTANT("E_RECOVERABLE_ERROR", E_RECOVERABLE_ERROR, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_LONG_CONSTANT("E_WARNING", E_WARNING, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_LONG_CONSTANT("E_PARSE", E_PARSE, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_LONG_CONSTANT("E_NOTICE", E_NOTICE, CONST_PERSISTENT | CONST_CS); diff --git a/Zend/zend_errors.h b/Zend/zend_errors.h index c89bbfe011..9c8fa88be3 100644 --- a/Zend/zend_errors.h +++ b/Zend/zend_errors.h @@ -34,8 +34,9 @@ #define E_USER_WARNING (1<<9L) #define E_USER_NOTICE (1<<10L) #define E_STRICT (1<<11L) +#define E_RECOVERABLE_ERROR (1<<12L) -#define E_ALL (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE) +#define E_ALL (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_RECOVERABLE_ERROR) #define E_CORE (E_CORE_ERROR | E_CORE_WARNING) #endif /* ZEND_ERRORS_H */ diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 67cb38e1e2..787f768a82 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -487,18 +487,18 @@ static inline void zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zv if (cur_arg_info->class_name) { if (!arg) { if (ptr && ptr->op_array) { - zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an object of class %v, called in %s on line %d and defined", arg_num, fclass, fsep, fname, cur_arg_info->class_name, ptr->op_array->filename, ptr->opline->lineno); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an object of class %v, called in %s on line %d and defined", arg_num, fclass, fsep, fname, cur_arg_info->class_name, ptr->op_array->filename, ptr->opline->lineno); } else { - zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an object of class %v", arg_num, fclass, fsep, fname, cur_arg_info->class_name); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an object of class %v", arg_num, fclass, fsep, fname, cur_arg_info->class_name); } } switch (Z_TYPE_P(arg)) { case IS_NULL: if (!cur_arg_info->allow_null) { if (ptr && ptr->op_array) { - zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must not be null, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must not be null, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno); } else { - zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must not be null", arg_num, fclass, fsep, fname); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must not be null", arg_num, fclass, fsep, fname); } } break; @@ -513,36 +513,36 @@ static inline void zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zv error_msg = "be an instance of"; } if (ptr && ptr->op_array) { - zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must %s %v, called in %s on line %d and defined", arg_num, fclass, fsep, fname, error_msg, ce->name, ptr->op_array->filename, ptr->opline->lineno); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must %s %v, called in %s on line %d and defined", arg_num, fclass, fsep, fname, error_msg, ce->name, ptr->op_array->filename, ptr->opline->lineno); } else { - zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must %s %v", arg_num, fclass, fsep, fname, error_msg, ce->name); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must %s %v", arg_num, fclass, fsep, fname, error_msg, ce->name); } } } break; default: if (ptr && ptr->op_array) { - zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an object of class %v, called in %s on line %d and defined", arg_num, fclass, fsep, fname, cur_arg_info->class_name, ptr->op_array->filename, ptr->opline->lineno); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an object of class %v, called in %s on line %d and defined", arg_num, fclass, fsep, fname, cur_arg_info->class_name, ptr->op_array->filename, ptr->opline->lineno); } else { - zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an object of class %v", arg_num, fclass, fsep, fname, cur_arg_info->class_name); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an object of class %v", arg_num, fclass, fsep, fname, cur_arg_info->class_name); } break; } } else if (cur_arg_info->array_type_hint) { if (!arg) { if (ptr && ptr->op_array) { - zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an array, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an array, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno); } else { - zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an array", arg_num, fclass, fsep, fname); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an array", arg_num, fclass, fsep, fname); } } switch (Z_TYPE_P(arg)) { case IS_NULL: if (!cur_arg_info->allow_null) { if (ptr && ptr->op_array) { - zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must not be null, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must not be null, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno); } else { - zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must not be null", arg_num, fclass, fsep, fname); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must not be null", arg_num, fclass, fsep, fname); } } break; @@ -550,9 +550,9 @@ static inline void zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zv break; default: if (ptr && ptr->op_array) { - zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an array, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an array, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno); } else { - zend_error_noreturn(E_ERROR, "Argument %d passed to %s%s%s() must be an array", arg_num, fclass, fsep, fname); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an array", arg_num, fclass, fsep, fname); } break; } diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index 352af2c824..3d7a5ef72c 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -1075,7 +1075,8 @@ static void php_mcrypt_do_crypt (char* cipher, zval **key, zval **data, char *mo } if (mcrypt_generic_init(td, key_s, use_key_length, iv_s) < 0) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Mcrypt initialisation failed"); + php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Mcrypt initialisation failed"); + RETURN_FALSE; } if (dencrypt == MCRYPT_ENCRYPT) { mcrypt_generic(td, data_s, data_size); diff --git a/ext/session/session.c b/ext/session/session.c index 571c4523b6..cbe30f4424 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -100,6 +100,7 @@ static PHP_INI_MH(OnUpdateSaveHandler) if (PG(modules_activated) && !PS(mod)) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Cannot find save handler %s", new_value); + return FAILURE; } return SUCCESS; @@ -126,6 +127,7 @@ static PHP_INI_MH(OnUpdateSerializer) if (PG(modules_activated) && !PS(serializer)) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Cannot find serialization handler %s", new_value); + return FAILURE; } return SUCCESS; diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 3aa725d581..2338c4f7d6 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1093,6 +1093,7 @@ static zval *sxe_get_value(zval *z TSRMLS_DC) if (sxe_object_cast(z, retval, IS_STRING, 0 TSRMLS_CC)==FAILURE) { zend_error(E_ERROR, "Unable to cast node to string"); + /* FIXME: Should not be fatal */ } retval->refcount = 0; @@ -1152,6 +1153,7 @@ static zend_object_value sxe_object_ze1_clone(zval *zobject TSRMLS_DC) { php_error(E_ERROR, "Cannot clone object of class %v due to 'zend.ze1_compatibility_mode'", Z_OBJCE_P(zobject)->name); /* Return zobject->value.obj just to satisfy compiler */ + /* FIXME: Should not be a fatal */ return zobject->value.obj; } diff --git a/ext/simplexml/tests/012.phpt b/ext/simplexml/tests/012.phpt index 79c01107fe..4bf7e1a0ec 100755 --- a/ext/simplexml/tests/012.phpt +++ b/ext/simplexml/tests/012.phpt @@ -36,4 +36,4 @@ Warning: main(): Cannot write or create unnamed attribute in %s012.php on line % -Fatal error: main(): Cannot create unnamed attribute in %s012.php on line %d +Catchable fatal error: main(): Cannot create unnamed attribute in %s012.php on line %d diff --git a/ext/spl/tests/array_013.phpt b/ext/spl/tests/array_013.phpt index 6d74bcb419..905b8339c9 100755 --- a/ext/spl/tests/array_013.phpt +++ b/ext/spl/tests/array_013.phpt @@ -78,4 +78,4 @@ one=>1 two=>2 ===Append=== -Fatal error: ArrayIterator::append(): Cannot append properties to objects, use ArrayIterator::offsetSet() instead in %sarray_013.php on line %d +Catchable fatal error: ArrayIterator::append(): Cannot append properties to objects, use ArrayIterator::offsetSet() instead in %sarray_013.php on line %d diff --git a/main/main.c b/main/main.c index aad569f0e5..de461dd7fe 100644 --- a/main/main.c +++ b/main/main.c @@ -805,6 +805,9 @@ static void php_error_cb(int type, const char *error_filename, const uint error_ case E_USER_ERROR: error_type_str = "Fatal error"; break; + case E_RECOVERABLE_ERROR: + error_type_str = "Catchable fatal error"; + break; case E_WARNING: case E_CORE_WARNING: case E_COMPILE_WARNING: @@ -886,6 +889,7 @@ static void php_error_cb(int type, const char *error_filename, const uint error_ } /* no break - intentionally */ case E_ERROR: + case E_RECOVERABLE_ERROR: /* case E_PARSE: the parser would return 1 (failure), we can bail out nicely */ case E_COMPILE_ERROR: case E_USER_ERROR: diff --git a/php.ini-dist b/php.ini-dist index afa73d6afc..dd2955c134 100644 --- a/php.ini-dist +++ b/php.ini-dist @@ -254,6 +254,7 @@ memory_limit = 8M ; Maximum amount of memory a script may consume (8MB) ; reporting level ; E_ALL - All errors and warnings (doesn't include E_STRICT) ; E_ERROR - fatal run-time errors +; E_RECOVERABLE_ERROR - almost fatal run-time errors ; E_WARNING - run-time warnings (non-fatal errors) ; E_PARSE - compile-time parse errors ; E_NOTICE - run-time notices (these are warnings which often result @@ -285,7 +286,7 @@ memory_limit = 8M ; Maximum amount of memory a script may consume (8MB) ; ; - Show only errors ; -;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR +;error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR ; ; - Show all errors except for notices and coding standards warnings ; diff --git a/php.ini-recommended b/php.ini-recommended index e6b9abf444..65757e3ebe 100644 --- a/php.ini-recommended +++ b/php.ini-recommended @@ -312,6 +312,7 @@ memory_limit = 8M ; Maximum amount of memory a script may consume (8MB) ; reporting level ; E_ALL - All errors and warnings (doesn't include E_STRICT) ; E_ERROR - fatal run-time errors +; E_RECOVERABLE_ERROR - almost fatal run-time errors ; E_WARNING - run-time warnings (non-fatal errors) ; E_PARSE - compile-time parse errors ; E_NOTICE - run-time notices (these are warnings which often result @@ -343,7 +344,7 @@ memory_limit = 8M ; Maximum amount of memory a script may consume (8MB) ; ; - Show only errors ; -;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR +;error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR ; ; - Show all errors, except coding standards warnings ; diff --git a/run-tests.php b/run-tests.php index 4453a4ffac..6ca4196453 100755 --- a/run-tests.php +++ b/run-tests.php @@ -143,7 +143,7 @@ $ini_overwrites = array( 'safe_mode=0', 'disable_functions=', 'output_buffering=Off', - 'error_reporting=4095', + 'error_reporting=8191', 'display_errors=1', 'log_errors=0', 'html_errors=0', diff --git a/tests/classes/array_access_003.phpt b/tests/classes/array_access_003.phpt index 7c65bedaf6..df0fde9f79 100644 --- a/tests/classes/array_access_003.phpt +++ b/tests/classes/array_access_003.phpt @@ -1,7 +1,7 @@ --TEST-- ZE2 ArrayAccess::offsetGet ambiguties --INI-- -error_reporting=4095 +error_reporting=8191 --FILE-- --FILE-- b($b); ?> --EXPECTF-- -Fatal error: Argument 1 must implement interface Foo, called in %s on line 27 and defined in %s on line 12 +Catchable fatal error: Argument 1 must implement interface Foo, called in %s on line 27 and defined in %s on line 12 diff --git a/tests/lang/bug24658.phpt b/tests/lang/bug24658.phpt index 399fd32cac..f799b17d5c 100644 --- a/tests/lang/bug24658.phpt +++ b/tests/lang/bug24658.phpt @@ -53,4 +53,4 @@ int(2) object(foo)#%d (0) { } -Fatal error: Argument 1 must be an object of class foo in %s on line %d +Catchable fatal error: Argument 1 must be an object of class foo in %s on line %d diff --git a/tests/lang/type_hints_001.phpt b/tests/lang/type_hints_001.phpt index 2aea3e703e..2af109632c 100644 --- a/tests/lang/type_hints_001.phpt +++ b/tests/lang/type_hints_001.phpt @@ -23,4 +23,4 @@ type_hint_foo($bar); ?> --EXPECTF-- -Fatal error: Argument 1 must be an instance of Foo, called in %s on line 16 and defined in %s on line 9 +Catchable fatal error: Argument 1 must be an instance of Foo, called in %s on line 16 and defined in %s on line 9 diff --git a/tests/run-test/test005.phpt b/tests/run-test/test005.phpt index b54cbc50e6..d16a66ef7a 100644 --- a/tests/run-test/test005.phpt +++ b/tests/run-test/test005.phpt @@ -24,7 +24,7 @@ var_dump($php_errormsg); ?> --EXPECTF-- string(1) "1" -string(4) "4095" +string(4) "8191" string(1) "0" string(1) "1" string(1) "0" diff --git a/tests/run-test/test008a.phpt b/tests/run-test/test008a.phpt index 7916ff2352..a7d360dc64 100644 --- a/tests/run-test/test008a.phpt +++ b/tests/run-test/test008a.phpt @@ -24,7 +24,7 @@ var_dump($php_errormsg); ?> --EXPECTF-- string(1) "1" -string(4) "4095" +string(4) "8191" string(1) "0" string(1) "1" string(1) "0"