Closes GH-6049.
zend_execute_data *ex;
const zend_op *opline;
- switch (type) {
- case E_CORE_ERROR:
- case E_ERROR:
- case E_RECOVERABLE_ERROR:
- case E_PARSE:
- case E_COMPILE_ERROR:
- case E_USER_ERROR:
- ex = EG(current_execute_data);
- opline = NULL;
- while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) {
- ex = ex->prev_execute_data;
- }
- if (ex && ex->opline->opcode == ZEND_HANDLE_EXCEPTION &&
- EG(opline_before_exception)) {
- opline = EG(opline_before_exception);
- }
- zend_exception_error(EG(exception), E_WARNING);
- EG(exception) = NULL;
- if (opline) {
- ex->opline = opline;
- }
- break;
- default:
- break;
+ if (type & E_FATAL_ERRORS) {
+ ex = EG(current_execute_data);
+ opline = NULL;
+ while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) {
+ ex = ex->prev_execute_data;
+ }
+ if (ex && ex->opline->opcode == ZEND_HANDLE_EXCEPTION &&
+ EG(opline_before_exception)) {
+ opline = EG(opline_before_exception);
+ }
+ zend_exception_error(EG(exception), E_WARNING);
+ EG(exception) = NULL;
+ if (opline) {
+ ex->opline = opline;
+ }
}
}
use_exceptions = 1;
}
- if ((error_num == E_USER_ERROR ||
- error_num == E_COMPILE_ERROR ||
- error_num == E_CORE_ERROR ||
- error_num == E_ERROR ||
- error_num == E_PARSE) &&
- use_exceptions) {
+ if ((error_num & E_FATAL_ERRORS) && use_exceptions) {
zval fault;
char *code = SOAP_GLOBAL(error_code);
if (code == NULL) {
int fault = 0;
zval fault_obj;
- if (error_num == E_USER_ERROR ||
- error_num == E_COMPILE_ERROR ||
- error_num == E_CORE_ERROR ||
- error_num == E_ERROR ||
- error_num == E_PARSE) {
-
+ if (error_num & E_FATAL_ERRORS) {
char* code = SOAP_GLOBAL(error_code);
zend_string *buffer;
zval outbuf;
/* according to error handling mode, throw exception or show it */
if (EG(error_handling) == EH_THROW) {
switch (type) {
- case E_ERROR:
- case E_CORE_ERROR:
- case E_COMPILE_ERROR:
- case E_USER_ERROR:
- case E_PARSE:
- /* fatal errors are real errors and cannot be made exceptions */
- break;
- case E_STRICT:
- case E_DEPRECATED:
- case E_USER_DEPRECATED:
- /* for the sake of BC to old damaged code */
- break;
- case E_NOTICE:
- case E_USER_NOTICE:
- /* notices are no errors and are not treated as such like E_WARNINGS */
- break;
- default:
- /* throw an exception if we are in EH_THROW mode
- * but DO NOT overwrite a pending exception
+ case E_WARNING:
+ case E_CORE_WARNING:
+ case E_COMPILE_WARNING:
+ case E_USER_WARNING:
+ /* throw an exception if we are in EH_THROW mode and the type is warning.
+ * fatal errors are real errors and cannot be made exceptions.
+ * exclude deprecated for the sake of BC to old damaged code.
+ * notices are no errors and are not treated as such like E_WARNINGS.
+ * DO NOT overwrite a pending exception.
*/
if (!EG(exception)) {
zend_throw_error_exception(EG(exception_class), message, 0, type);
}
return;
+ default:
+ break;
}
}
zend_bool append_error_message = 0;
if (PG(last_error_message)) {
- switch (PG(last_error_type)) {
- case E_ERROR:
- case E_CORE_ERROR:
- case E_COMPILE_ERROR:
- case E_USER_ERROR:
- case E_PARSE:
- if (status == 200) {
- /* the status code isn't changed by a fatal error, so fake it */
- effective_status = 500;
- }
+ if (PG(last_error_type) & E_FATAL_ERRORS) {
+ if (status == 200) {
+ /* the status code isn't changed by a fatal error, so fake it */
+ effective_status = 500;
+ }
- append_error_message = 1;
- break;
+ append_error_message = 1;
}
}
return;
}
- switch (PG(last_error_type)) {
- case E_ERROR:
- case E_CORE_ERROR:
- case E_COMPILE_ERROR:
- case E_USER_ERROR:
- case E_PARSE:
- case E_RECOVERABLE_ERROR: {
- const char *file_char = zend_get_executed_filename();
- zend_string *file = zend_string_init(file_char, strlen(file_char), 0);
- phpdbg_list_file(file, 3, zend_get_executed_lineno() - 1, zend_get_executed_lineno());
- zend_string_release(file);
-
- if (!phpdbg_fully_started) {
- return;
- }
-
- do {
- switch (phpdbg_interactive(1, NULL)) {
- case PHPDBG_LEAVE:
- case PHPDBG_FINISH:
- case PHPDBG_UNTIL:
- case PHPDBG_NEXT:
- return;
- }
- } while (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING));
+ if (PG(last_error_type) & E_FATAL_ERRORS) {
+ const char *file_char = zend_get_executed_filename();
+ zend_string *file = zend_string_init(file_char, strlen(file_char), 0);
+ phpdbg_list_file(file, 3, zend_get_executed_lineno() - 1, zend_get_executed_lineno());
+ zend_string_release(file);
+
+ if (!phpdbg_fully_started) {
+ return;
}
+
+ do {
+ switch (phpdbg_interactive(1, NULL)) {
+ case PHPDBG_LEAVE:
+ case PHPDBG_FINISH:
+ case PHPDBG_UNTIL:
+ case PHPDBG_NEXT:
+ return;
+ }
+ } while (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING));
}
} else {
fprintf(stdout, "%s\n", message);