diff --git a/admin/check/check_config_inc.php b/admin/check/check_config_inc.php index 508aab6662..3d35d40149 100644 --- a/admin/check/check_config_inc.php +++ b/admin/check/check_config_inc.php @@ -56,7 +56,7 @@ ); check_print_test_warn_row( 'MantisBT Application Errors should halt execution', - $g_display_errors[E_USER_ERROR] == 'halt', + $g_display_errors[E_USER_ERROR] == DISPLAY_ERROR_HALT, array( false => 'Continuing after an error may lead to system and/or data integrity issues. Set $g_display_errors[E_USER_ERROR] = \'halt\';' ) ); diff --git a/config_defaults_inc.php b/config_defaults_inc.php index e56bc676c8..efac5f44f6 100644 --- a/config_defaults_inc.php +++ b/config_defaults_inc.php @@ -4089,38 +4089,41 @@ /** * Errors Display method * Defines what errors are displayed and how. Available options are: - * - 'halt' stop and display error message (including variables and - * backtrace if {@link $g_show_detailed_errors} is ON) - * - 'inline' display 1 line error and continue execution - * - 'none' no error displayed + * - DISPLAY_ERROR_HALT stop and display error message (including + * variables and backtrace if + * {@link $g_show_detailed_errors} is ON) + * - DISPLAY_ERROR_INLINE display 1 line error and continue execution + * - DISPLAY_ERROR_NONE no error displayed * - * WARNING: E_USER_ERROR should always be set to 'halt'. Using another value - * will cause program execution to continue, which may lead to data integrity - * issues and/or cause MantisBT to function incorrectly. + * WARNING: E_USER_ERROR should always be set to DISPLAY_ERROR_HALT. Using + * another value will cause program execution to continue, which may lead to + * data integrity issues and/or cause MantisBT to function incorrectly. * * A developer might set this in config_inc.php as: * $g_display_errors = array( - * E_WARNING => 'halt', - * E_NOTICE => 'inline', - * E_USER_ERROR => 'halt', - * E_USER_WARNING => 'inline', - * E_USER_NOTICE => 'inline' + * E_WARNING => DISPLAY_ERROR_HALT, + * E_NOTICE => DISPLAY_ERROR_INLINE, + * E_USER_ERROR => DISPLAY_ERROR_HALT, + * E_USER_WARNING => DISPLAY_ERROR_INLINE, + * E_USER_NOTICE => DISPLAY_ERROR_INLINE * ); * * @global array $g_display_errors */ $g_display_errors = array( - E_WARNING => 'inline', - E_NOTICE => 'none', - E_USER_ERROR => 'halt', - E_USER_WARNING => 'inline', - E_USER_NOTICE => 'none' + E_WARNING => DISPLAY_ERROR_INLINE, + E_NOTICE => DISPLAY_ERROR_NONE, + E_USER_ERROR => DISPLAY_ERROR_HALT, + E_USER_WARNING => DISPLAY_ERROR_INLINE, + E_USER_NOTICE => DISPLAY_ERROR_NONE ); /** * Detailed error messages * Shows a list of variables and their values when an error is triggered. - * Only applies to error types configured to 'halt' in {@link $g_display_errors} + * Only applies to error types configured to DISPLAY_ERROR_HALT in + * {@link $g_display_errors} + * * WARNING: Potential security hazard. Only turn this on when you really * need it for debugging * diff --git a/core/constant_inc.php b/core/constant_inc.php index 76e0ccd971..637522644e 100644 --- a/core/constant_inc.php +++ b/core/constant_inc.php @@ -498,6 +498,11 @@ define( 'CUSTOM_FIELD_TYPE_PROJECT', 3 ); define( 'CUSTOM_FIELD_TYPE_FILE', 4 ); +# display types for $g_display_errors +define( 'DISPLAY_ERROR_HALT', 'halt' ); +define( 'DISPLAY_ERROR_INLINE', 'inline' ); +define( 'DISPLAY_ERROR_NONE', 'none' ); + # system logging # The logging levels can be combined using bitwise operators define( 'LOG_ALL', ~0 ); # All possible log levels diff --git a/core/error_api.php b/core/error_api.php index ffafddefd8..1584e478f3 100644 --- a/core/error_api.php +++ b/core/error_api.php @@ -124,7 +124,7 @@ function error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) { case E_USER_ERROR: $t_error_type = "APPLICATION ERROR #$p_error"; $t_error_description = error_string( $p_error ); - if( $t_method == 'inline' ) { + if( $t_method == DISPLAY_ERROR_INLINE ) { $t_error_description .= "\n" . error_string( ERROR_DISPLAY_USER_ERROR_INLINE ); } break; @@ -148,7 +148,7 @@ function error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) { $t_error_description = nl2br( $t_error_description ); switch( $t_method ) { - case 'halt': + case DISPLAY_ERROR_HALT: # disable any further event callbacks if ( function_exists( 'event_clear_callbacks' ) ) { event_clear_callbacks(); @@ -234,7 +234,7 @@ function error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) { echo '', "\n"; } exit(); - case 'inline': + case DISPLAY_ERROR_INLINE: echo '
', $t_error_type, ': ', $t_error_description, '
'; $g_error_handled = true; break; diff --git a/docbook/Admin_Guide/en-US/Configuration.xml b/docbook/Admin_Guide/en-US/Configuration.xml index dcec6ec9bb..660600adf3 100644 --- a/docbook/Admin_Guide/en-US/Configuration.xml +++ b/docbook/Admin_Guide/en-US/Configuration.xml @@ -3511,7 +3511,7 @@ $g_main_menu_custom_options = array( - halt + DISPLAY_ERROR_HALT stop and display error message (including variables and backtrace if @@ -3521,7 +3521,7 @@ $g_main_menu_custom_options = array( - inline + DISPLAY_ERROR_INLINE display 1 line error and continue execution @@ -3529,7 +3529,7 @@ $g_main_menu_custom_options = array( - none + DISPLAY_ERROR_NONE no error displayed @@ -3539,27 +3539,28 @@ $g_main_menu_custom_options = array( Default is $g_display_errors = array( - E_WARNING => 'inline', - E_NOTICE => 'none', - E_USER_ERROR => 'halt', - E_USER_WARNING => 'inline', - E_USER_NOTICE => 'none' + E_WARNING => DISPLAY_ERROR_INLINE, + E_NOTICE => DISPLAY_ERROR_NONE, + E_USER_ERROR => DISPLAY_ERROR_HALT, + E_USER_WARNING => DISPLAY_ERROR_INLINE, + E_USER_NOTICE => DISPLAY_ERROR_NONE ); A developer might set this in their config_inc.php as: $g_display_errors = array( - E_WARNING => 'halt', - E_NOTICE => 'inline', - E_USER_ERROR => 'halt', - E_USER_WARNING => 'inline', - E_USER_NOTICE => 'inline' + E_WARNING => DISPLAY_ERROR_HALT, + E_NOTICE => DISPLAY_ERROR_INLINE, + E_USER_ERROR => DISPLAY_ERROR_HALT, + E_USER_WARNING => DISPLAY_ERROR_INLINE, + E_USER_NOTICE => DISPLAY_ERROR_INLINE ); E_USER_ERROR - should always be set to 'halt'. + should always be set to + DISPLAY_ERROR_HALT. Using any other value will cause program execution to continue despite the error, which may lead to data integrity issues and/or cause MantisBT to function @@ -3573,7 +3574,8 @@ $g_display_errors = array( Shows a list of variables and their values whenever an error is triggered. - Only applies to error types configured to 'halt' + Only applies to error types configured to + DISPLAY_ERROR_HALT in $g_display_errors. Default is OFF. diff --git a/login_page.php b/login_page.php index 0f946bf32c..1db3e048dc 100644 --- a/login_page.php +++ b/login_page.php @@ -228,8 +228,12 @@ function debug_setting_message ( $p_type, $p_setting, $p_value ) { $t_warnings[] = debug_setting_message( 'security', $t_config, 'OFF' ); } $t_config = 'display_errors'; - if( config_get_global( $t_config )[E_USER_ERROR] != 'halt' ) { - $t_warnings[] = debug_setting_message( 'integrity', $t_config . '[E_USER_ERROR]', 'halt' ); + if( config_get_global( $t_config )[E_USER_ERROR] != DISPLAY_ERROR_HALT ) { + $t_warnings[] = debug_setting_message( + 'integrity', + $t_config . '[E_USER_ERROR]', + DISPLAY_ERROR_HALT + ); } $t_debug_email = config_get( 'debug_email' ); if( $t_debug_email !== OFF ) {