From 4b97f40af90057ff8b06c5f7caf0b4c208a949c7 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 22 May 2018 11:12:24 +0200 Subject: [PATCH] Get rid of debug_level (#6298) --- CHANGELOG | 1 + INSTALL | 4 +- config/defaults.inc.php | 3 -- installer/config.php | 16 ------- program/include/rcmail_install.php | 11 +---- program/lib/Roundcube/rcube.php | 61 +++++++------------------- program/lib/Roundcube/rcube_config.php | 14 ++---- program/steps/utils/error.inc | 9 +--- 8 files changed, 27 insertions(+), 92 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6d9b02b7e..e0c916b0f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -66,6 +66,7 @@ CHANGELOG Roundcube Webmail - Plugin API: Added 'show_bytes' hook (#5001) - Add option to not indent quoted text on top-posting reply (#5105) - Removed global $CONFIG variable +- Removed debug_level setting - Support AUTHENTICATE LOGIN for IMAP connections (#5563) - Support LDAP GSSAPI authentication (#5703) - Localized timezone selector (#4983) diff --git a/INSTALL b/INSTALL index 7971bcf8a..940415444 100644 --- a/INSTALL +++ b/INSTALL @@ -76,7 +76,9 @@ and configure your installation to be not surprised by default behaviour. Roundcube writes internal errors to the 'errors' log file located in the logs directory which can be configured in config/config.inc.php. If you want ordinary -PHP errors to be logged there as well, set error_log php.ini or .htaccess file. +PHP errors to be logged there as well, set error_log in php.ini or .htaccess file. + +Roundcube forces display_errors=Off and log_errors=On. By default the session cookie settings of PHP are not modified by Roundcube. However if you want to limit the session cookies to the directory where diff --git a/config/defaults.inc.php b/config/defaults.inc.php index 988a35f41..b00ac76a7 100644 --- a/config/defaults.inc.php +++ b/config/defaults.inc.php @@ -63,9 +63,6 @@ $config['db_max_allowed_packet'] = null; // LOGGING/DEBUGGING // ---------------------------------- -// system error reporting, sum of: 1 = log; 4 = show -$config['debug_level'] = 1; - // log driver: 'syslog', 'stdout' or 'file'. $config['log_driver'] = 'file'; diff --git a/installer/config.php b/installer/config.php index dd14c24cb..90fa9929c 100644 --- a/installer/config.php +++ b/installer/config.php @@ -11,7 +11,6 @@ $RCI->bool_config_props = array( 'auto_create_user' => 1, 'smtp_log' => 1, 'prefer_html' => 1, - 'debug_level' => 1, ); // allow the current user to get to the next step @@ -196,21 +195,6 @@ echo $input_ilevel->show($RCI->getprop('identities_level'), 0); Logging & Debugging
-
debug_level
-
-getprop('debug_level'); -$check_debug = new html_checkbox(array('name' => '_debug_level[]')); -echo $check_debug->show(($value & 1) ? 1 : 0 , array('value' => 1, 'id' => 'cfgdebug1')); -echo '
'; - -echo $check_debug->show(($value & 4) ? 4 : 0, array('value' => 4, 'id' => 'cfgdebug4')); -echo '
'; - -?> -
-
log_driver
config->get('debug_level'); - - // disable errors for ajax requests, write to log instead (#1487831) - if (($level & 4) && !empty($_REQUEST['_remote'])) { - $level = ($level ^ 4) | 1; - } // write error to local log file - if (($level & 1) || !empty($arg_arr['fatal'])) { - if ($_SERVER['REQUEST_METHOD'] == 'POST') { - foreach (array('_task', '_action') as $arg) { - if ($_POST[$arg] && !$_GET[$arg]) { - $post_query[$arg] = $_POST[$arg]; - } - } - - if (!empty($post_query)) { - $post_query = (strpos($_SERVER['REQUEST_URI'], '?') != false ? '&' : '?') - . http_build_query($post_query, '', '&'); + if ($_SERVER['REQUEST_METHOD'] == 'POST') { + foreach (array('_task', '_action') as $arg) { + if ($_POST[$arg] && !$_GET[$arg]) { + $post_query[$arg] = $_POST[$arg]; } } - $log_entry = sprintf("%s Error: %s%s (%s %s)", - $program, - $arg_arr['message'], - $arg_arr['file'] ? sprintf(' in %s on line %d', $arg_arr['file'], $arg_arr['line']) : '', - $_SERVER['REQUEST_METHOD'], - $_SERVER['REQUEST_URI'] . $post_query); - - if (!self::write_log('errors', $log_entry)) { - // send error to PHPs error handler if write_log didn't succeed - trigger_error($arg_arr['message'], E_USER_WARNING); + if (!empty($post_query)) { + $post_query = (strpos($_SERVER['REQUEST_URI'], '?') != false ? '&' : '?') + . http_build_query($post_query, '', '&'); } } - // report the bug to the global bug reporting system - if ($level & 2) { - // TODO: Send error via HTTP - } - - // show error if debug_mode is on - if ($level & 4) { - print "$program Error"; - - if (!empty($arg_arr['file']) && !empty($arg_arr['line'])) { - print " in $arg_arr[file] ($arg_arr[line])"; - } + $log_entry = sprintf("%s Error: %s%s (%s %s)", + $program, + $arg_arr['message'], + $arg_arr['file'] ? sprintf(' in %s on line %d', $arg_arr['file'], $arg_arr['line']) : '', + $_SERVER['REQUEST_METHOD'], + $_SERVER['REQUEST_URI'] . $post_query); - print ': '; - print nl2br($arg_arr['message']); - print '
'; - flush(); + if (!self::write_log('errors', $log_entry)) { + // send error to PHPs error handler if write_log didn't succeed + trigger_error($arg_arr['message'], E_USER_WARNING); } } diff --git a/program/lib/Roundcube/rcube_config.php b/program/lib/Roundcube/rcube_config.php index 300337ae7..73e7738a6 100644 --- a/program/lib/Roundcube/rcube_config.php +++ b/program/lib/Roundcube/rcube_config.php @@ -245,20 +245,14 @@ class rcube_config } // set PHP error logging according to config - if ($this->prop['debug_level'] & 1) { - $error_log = $this->prop['log_driver']; - if ($error_log != 'syslog') { - $error_log = $this->prop['log_dir'] . '/errors'; - $error_log .= isset($this->prop['log_file_ext']) ? $this->prop['log_file_ext'] : '.log'; - } + $error_log = $this->prop['log_driver']; + if ($error_log != 'syslog') { + $error_log = $this->prop['log_dir'] . '/errors'; + $error_log .= isset($this->prop['log_file_ext']) ? $this->prop['log_file_ext'] : '.log'; ini_set('error_log', $error_log); - ini_set('log_errors', 1); } - // enable display_errors in 'show' level, but not for ajax requests - ini_set('display_errors', intval(empty($_REQUEST['_remote']) && ($this->prop['debug_level'] & 4))); - // remove deprecated properties unset($this->prop['dst_active']); } diff --git a/program/steps/utils/error.inc b/program/steps/utils/error.inc index 9e134fb7a..773fe71fe 100644 --- a/program/steps/utils/error.inc +++ b/program/steps/utils/error.inc @@ -96,14 +96,7 @@ else if ($ERROR_CODE == 603) { // system error else { $__error_title = "SERVICE CURRENTLY NOT AVAILABLE!"; - $__error_text = "Please contact your server-administrator."; - - if (($rcmail->config->get('debug_level') & 4) && $ERROR_MESSAGE) { - $__error_text = $ERROR_MESSAGE; - } - else { - $__error_text = sprintf('Error No. [%s]', $ERROR_CODE); - } + $__error_text = sprintf('Error No. [%s]', $ERROR_CODE); } // inform plugins