From 7085a6c74d9bc5a4c5a92033977a89f56cce01e1 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 10 Nov 2012 10:12:25 -0600 Subject: [PATCH 1/2] [ticket/11189] Always log critical errors when in cron or in image output PHPBB3-11189 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 43b81f3f26..7801c48aa7 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4196,7 +4196,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $msg_text = $log_text; } - if ((defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db)) + if ((defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db)) { // let's avoid loops $db->sql_return_on_error(true); From bd37f7f6c04780819dfa8f81b2d761b91859fd67 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 10 Nov 2012 10:45:02 -0600 Subject: [PATCH 2/2] [ticket/11189] Replace DEBUG_EXTRA with DEBUG PHPBB3-11189 --- phpBB/cron.php | 6 +++--- phpBB/feed.php | 2 +- phpBB/includes/db/dbal.php | 4 ++-- phpBB/includes/db/firebird.php | 6 +++--- phpBB/includes/db/mssql.php | 6 +++--- phpBB/includes/db/mssql_odbc.php | 6 +++--- phpBB/includes/db/mssqlnative.php | 6 +++--- phpBB/includes/db/mysql.php | 6 +++--- phpBB/includes/db/mysqli.php | 6 +++--- phpBB/includes/db/oracle.php | 6 +++--- phpBB/includes/db/postgres.php | 6 +++--- phpBB/includes/db/sqlite.php | 6 +++--- phpBB/includes/functions.php | 6 +++--- phpBB/includes/functions_acp.php | 4 ++-- phpBB/includes/functions_install.php | 2 -- phpBB/includes/session.php | 2 +- phpBB/includes/template/template.php | 4 ++-- phpBB/includes/user.php | 10 +++++----- phpBB/install/database_update.php | 2 +- phpBB/install/install_convert.php | 8 ++++---- 20 files changed, 51 insertions(+), 53 deletions(-) diff --git a/phpBB/cron.php b/phpBB/cron.php index 95d2f8f9b6..787183f689 100644 --- a/phpBB/cron.php +++ b/phpBB/cron.php @@ -39,7 +39,7 @@ function do_cron($cron_lock, $run_tasks) foreach ($run_tasks as $task) { - if (defined('DEBUG_EXTRA') && $config['use_system_cron']) + if (defined('DEBUG') && $config['use_system_cron']) { echo "[phpBB cron] Running task '{$task->get_name()}'\n"; } @@ -57,7 +57,7 @@ function do_cron($cron_lock, $run_tasks) // // Attempt to alleviate the problem by doing setup outside of the lock as much as possible. // -// If DEBUG_EXTRA is defined and cron lock cannot be obtained, a message will be printed. +// If DEBUG is defined and cron lock cannot be obtained, a message will be printed. if ($config['use_system_cron']) { @@ -100,7 +100,7 @@ if ($cron_lock->acquire()) } else { - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { echo "Could not obtain cron lock.\n"; } diff --git a/phpBB/feed.php b/phpBB/feed.php index 9b7ef3a575..58ae251089 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -150,7 +150,7 @@ if ($config['gzip_compress']) } // IF debug extra is enabled and admin want to "explain" the page we need to set other headers... -if (defined('DEBUG_EXTRA') && request_var('explain', 0) && $auth->acl_get('a_')) +if (defined('DEBUG') && request_var('explain', 0) && $auth->acl_get('a_')) { header('Content-type: text/html; charset=UTF-8'); header('Cache-Control: private, no-cache="set-cookie"'); diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index 1de236d3de..ef1dd7d14d 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -766,8 +766,8 @@ class dbal // Show complete SQL error and path to administrators only // Additionally show complete error on installation or if extended debug mode is enabled - // The DEBUG_EXTRA constant is for development only! - if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG_EXTRA')) + // The DEBUG constant is for development only! + if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG')) { $message .= ($sql) ? '

SQL

' . htmlspecialchars($sql) : ''; } diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php index 9f9b8a1abd..5728eb901c 100644 --- a/phpBB/includes/db/firebird.php +++ b/phpBB/includes/db/firebird.php @@ -150,7 +150,7 @@ class dbal_firebird extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -251,7 +251,7 @@ class dbal_firebird extends dbal $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -279,7 +279,7 @@ class dbal_firebird extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php index bde283c3ea..1ec8517308 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/mssql.php @@ -139,7 +139,7 @@ class dbal_mssql extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -154,7 +154,7 @@ class dbal_mssql extends dbal $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -169,7 +169,7 @@ class dbal_mssql extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index 687bc52abc..7c1ffbc808 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -157,7 +157,7 @@ class dbal_mssql_odbc extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -173,7 +173,7 @@ class dbal_mssql_odbc extends dbal $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -188,7 +188,7 @@ class dbal_mssql_odbc extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php index c31f7f6892..e9191fae8a 100644 --- a/phpBB/includes/db/mssqlnative.php +++ b/phpBB/includes/db/mssqlnative.php @@ -311,7 +311,7 @@ class dbal_mssqlnative extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -329,7 +329,7 @@ class dbal_mssqlnative extends dbal // reset options for next query $this->query_options = array(); - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -344,7 +344,7 @@ class dbal_mssqlnative extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 5b4ff86579..f685ab055c 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -167,7 +167,7 @@ class dbal_mysql extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -182,7 +182,7 @@ class dbal_mysql extends dbal $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -197,7 +197,7 @@ class dbal_mysql extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php index 1f13bd5459..6d81b8bc3e 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/mysqli.php @@ -174,7 +174,7 @@ class dbal_mysqli extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -189,7 +189,7 @@ class dbal_mysqli extends dbal $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -199,7 +199,7 @@ class dbal_mysqli extends dbal $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php index de2729e973..6d9339b2d8 100644 --- a/phpBB/includes/db/oracle.php +++ b/phpBB/includes/db/oracle.php @@ -236,7 +236,7 @@ class dbal_oracle extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -413,7 +413,7 @@ class dbal_oracle extends dbal } } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -428,7 +428,7 @@ class dbal_oracle extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php index f0a4a7a7a2..8dfbfc3b60 100644 --- a/phpBB/includes/db/postgres.php +++ b/phpBB/includes/db/postgres.php @@ -194,7 +194,7 @@ class dbal_postgres extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -210,7 +210,7 @@ class dbal_postgres extends dbal $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -225,7 +225,7 @@ class dbal_postgres extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php index 2cf55b07e2..5fc89ced18 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/sqlite.php @@ -112,7 +112,7 @@ class dbal_sqlite extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -127,7 +127,7 @@ class dbal_sqlite extends dbal $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -142,7 +142,7 @@ class dbal_sqlite extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 7801c48aa7..804d89d1a2 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4191,7 +4191,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $log_text .= '

BACKTRACE
' . $backtrace; } - if (defined('IN_INSTALL') || defined('DEBUG_EXTRA') || isset($auth) && $auth->acl_get('a_')) + if (defined('IN_INSTALL') || defined('DEBUG') || isset($auth) && $auth->acl_get('a_')) { $msg_text = $log_text; } @@ -5241,14 +5241,14 @@ function page_footer($run_cron = true) $mtime = explode(' ', microtime()); $totaltime = $mtime[0] + $mtime[1] - $starttime; - if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report')) + if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG') && method_exists($db, 'sql_report')) { $db->sql_report('display'); } $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress'] && @extension_loaded('zlib')) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime); - if ($auth->acl_get('a_') && defined('DEBUG_EXTRA')) + if ($auth->acl_get('a_') && defined('DEBUG')) { if (function_exists('memory_get_peak_usage')) { diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 11cc1f6dd8..2f3fd7bac0 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -145,14 +145,14 @@ function adm_page_footer($copyright_html = true) $mtime = explode(' ', microtime()); $totaltime = $mtime[0] + $mtime[1] - $starttime; - if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report')) + if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG') && method_exists($db, 'sql_report')) { $db->sql_report('display'); } $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress']) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime); - if ($auth->acl_get('a_') && defined('DEBUG_EXTRA')) + if ($auth->acl_get('a_') && defined('DEBUG')) { if (function_exists('memory_get_peak_usage')) { diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 3421c90c88..7a799993db 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -528,12 +528,10 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_test if ($debug) { $config_data .= "@define('DEBUG', true);\n"; - $config_data .= "@define('DEBUG_EXTRA', true);\n"; } else { $config_data .= "// @define('DEBUG', true);\n"; - $config_data .= "// @define('DEBUG_EXTRA', true);\n"; } if ($debug_test) diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 257ffb07f6..ee8a4094c7 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -474,7 +474,7 @@ class phpbb_session else { // Added logging temporarly to help debug bugs... - if (defined('DEBUG_EXTRA') && $this->data['user_id'] != ANONYMOUS) + if (defined('DEBUG') && $this->data['user_id'] != ANONYMOUS) { if ($referer_valid) { diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php index 5d3ce4c82b..367c02aa15 100644 --- a/phpBB/includes/template/template.php +++ b/phpBB/includes/template/template.php @@ -250,7 +250,7 @@ class phpbb_template * If template cache is writable the compiled php code will be stored * on filesystem and template will not be subsequently recompiled. * If template cache is not writable template source will be recompiled - * every time it is needed. DEBUG_EXTRA define and load_tplcompile + * every time it is needed. DEBUG define and load_tplcompile * configuration setting may be used to force templates to be always * recompiled. * @@ -268,7 +268,7 @@ class phpbb_template { $output_file = $this->_compiled_file_for_handle($handle); - $recompile = defined('DEBUG_EXTRA') || + $recompile = defined('DEBUG') || !file_exists($output_file) || @filesize($output_file) === 0; diff --git a/phpBB/includes/user.php b/phpBB/includes/user.php index 93557f3558..9ddd806b27 100644 --- a/phpBB/includes/user.php +++ b/phpBB/includes/user.php @@ -162,8 +162,8 @@ class phpbb_user extends phpbb_session // We include common language file here to not load it every time a custom language file is included $lang = &$this->lang; - // Do not suppress error if in DEBUG_EXTRA mode - $include_result = (defined('DEBUG_EXTRA')) ? (include $this->lang_path . $this->lang_name . "/common.$phpEx") : (@include $this->lang_path . $this->lang_name . "/common.$phpEx"); + // Do not suppress error if in DEBUG mode + $include_result = (defined('DEBUG')) ? (include $this->lang_path . $this->lang_name . "/common.$phpEx") : (@include $this->lang_path . $this->lang_name . "/common.$phpEx"); if ($include_result === false) { @@ -252,7 +252,7 @@ class phpbb_user extends phpbb_session // Disable board if the install/ directory is still present // For the brave development army we do not care about this, else we need to comment out this everytime we develop locally - if (!defined('DEBUG_EXTRA') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) + if (!defined('DEBUG') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) { // Adjust the message slightly according to the permissions if ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) @@ -618,8 +618,8 @@ class phpbb_user extends phpbb_session return; } - // Do not suppress error if in DEBUG_EXTRA mode - $include_result = (defined('DEBUG_EXTRA')) ? (include $language_filename) : (@include $language_filename); + // Do not suppress error if in DEBUG mode + $include_result = (defined('DEBUG')) ? (include $language_filename) : (@include $language_filename); if ($include_result === false) { diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index dcdd17cbc0..899394cd08 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -620,7 +620,7 @@ function _sql($sql, &$errored, &$error_ary, $echo_dot = true) { global $db; - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { echo "
\n{$sql}\n
"; } diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php index b8045cb98b..41de9de44c 100644 --- a/phpBB/install/install_convert.php +++ b/phpBB/install/install_convert.php @@ -1196,7 +1196,7 @@ class install_convert extends module $template->assign_block_vars('checks', array( 'TITLE' => "skip_rows = $skip_rows", - 'RESULT' => $rows . ((defined('DEBUG_EXTRA') && function_exists('memory_get_usage')) ? ceil(memory_get_usage()/1024) . ' ' . $user->lang['KIB'] : ''), + 'RESULT' => $rows . ((defined('DEBUG') && function_exists('memory_get_usage')) ? ceil(memory_get_usage()/1024) . ' ' . $user->lang['KIB'] : ''), )); $mtime = explode(' ', microtime()); @@ -1380,7 +1380,7 @@ class install_convert extends module } // When we reach this point, either the current table has been processed or we're running out of time. - if (still_on_time() && $counting < $convert->batch_size/* && !defined('DEBUG_EXTRA')*/) + if (still_on_time() && $counting < $convert->batch_size/* && !defined('DEBUG')*/) { $skip_rows = 0; $current_table++; @@ -1469,7 +1469,7 @@ class install_convert extends module sync('topic', 'range', 'topic_id BETWEEN ' . $sync_batch . ' AND ' . $end, true, true); $template->assign_block_vars('checks', array( - 'TITLE' => sprintf($user->lang['SYNC_TOPIC_ID'], $sync_batch, ($sync_batch + $batch_size)) . ((defined('DEBUG_EXTRA') && function_exists('memory_get_usage')) ? ' [' . ceil(memory_get_usage()/1024) . ' ' . $user->lang['KIB'] . ']' : ''), + 'TITLE' => sprintf($user->lang['SYNC_TOPIC_ID'], $sync_batch, ($sync_batch + $batch_size)) . ((defined('DEBUG') && function_exists('memory_get_usage')) ? ' [' . ceil(memory_get_usage()/1024) . ' ' . $user->lang['KIB'] . ']' : ''), 'RESULT' => $user->lang['DONE'], )); @@ -1757,7 +1757,7 @@ class install_convert extends module global $convert; // Can we use IGNORE with this DBMS? - $sql_ignore = (strpos($db->sql_layer, 'mysql') === 0 && !defined('DEBUG_EXTRA')) ? 'IGNORE ' : ''; + $sql_ignore = (strpos($db->sql_layer, 'mysql') === 0 && !defined('DEBUG')) ? 'IGNORE ' : ''; $insert_query = 'INSERT ' . $sql_ignore . 'INTO ' . $schema['target'] . ' ('; $aliases = array();