From: Janusz Dobrowolski Date: Mon, 21 Jun 2010 17:17:44 +0000 (+0000) Subject: Support for debugging sql queries in page footer. X-Git-Tag: v2.4.2~19^2~836 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=666628871766f00f177ff4cf7481167a86a07863;p=fa-stable.git Support for debugging sql queries in page footer. --- diff --git a/admin/system_diagnostics.php b/admin/system_diagnostics.php index 8fba1810..e1d89618 100644 --- a/admin/system_diagnostics.php +++ b/admin/system_diagnostics.php @@ -114,7 +114,7 @@ function tst_debug() $test['type'] = 0; $test['test'] = $go_debug ? _("Yes") : _("No"); $test['result'] = $go_debug != 0; - $test['comments'] = _('To switch debugging on set $go_debug=1 in config.php file'); + $test['comments'] = _('To switch debugging on set $go_debug>1 in config.php file'); return $test; } diff --git a/config.default.php b/config.default.php index 747d6f26..84c8578f 100644 --- a/config.default.php +++ b/config.default.php @@ -25,10 +25,11 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_ // Special value 'syslog' can be used for system logger usage (see php manual). //$error_logfile = ''; $error_logfile = dirname(__FILE__).'/tmp/errors.log'; - $debug = 1; - $show_sql = 0; - $go_debug = 0; - $pdf_debug = 0; + $debug = 1; // show sql on database errors + + $show_sql = 0; // show all sql queries in page footer for debugging purposes + $go_debug = 0; // set to 1 for basic debugging, or 2 to see also backtrace after failure. + $pdf_debug = 0; // display pdf source instead reports for debugging when $go_debug!=0 // set $sql_trail to 1 only if you want to perform bugtracking sql trail // Warning: this produces huge amount of data in sql_trail table. // Don't forget switch the option off and flush the table manually after @@ -36,7 +37,7 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_ // $sql_trail = 0; // save all sql queries in sql_trail $select_trail = 0; // track also SELECT queries - if ($go_debug == 1) + if ($go_debug > 0) { error_reporting(E_ALL); ini_set("display_errors", "On"); diff --git a/includes/db/connect_db.inc b/includes/db/connect_db.inc index 3e0d551f..5babac1b 100644 --- a/includes/db/connect_db.inc +++ b/includes/db/connect_db.inc @@ -26,16 +26,13 @@ $db_duplicate_error_code = 1062; function db_query($sql, $err_msg=null) { - global $db, $show_sql, $sql_trail, $select_trail, $go_debug; + global $db, $show_sql, $sql_trail, $select_trail, $go_debug, $sql_queries, $Ajax; if ($show_sql) { - echo "SQL.."; - echo "
";
-		echo $sql;
-		echo "
\n"; + $Ajax->activate('footer_debug'); + $sql_queries .= "
$sql
\n
"; } - $result = mysql_query($sql, $db); if($sql_trail) { diff --git a/includes/errors.inc b/includes/errors.inc index 9e0dba2e..16b5be40 100644 --- a/includes/errors.inc +++ b/includes/errors.inc @@ -108,7 +108,7 @@ function end_flush() { function display_db_error($msg, $sql_statement=null, $exit=true) { - global $db, $debug; + global $db, $debug, $go_debug; $warning = $msg==null; $db_error = db_error_no(); @@ -128,6 +128,7 @@ function display_db_error($msg, $sql_statement=null, $exit=true) if ($debug == 1) { $str .= "sql that failed was : " . $sql_statement . "
"; + if ($go_debug > 1) display_backtrace(); } $str .= "

"; diff --git a/includes/page/footer.inc b/includes/page/footer.inc index 23318932..68f76f35 100644 --- a/includes/page/footer.inc +++ b/includes/page/footer.inc @@ -11,7 +11,7 @@ ***********************************************************************/ function page_footer($no_menu=false, $is_index=false, $hide_back_link=false) { - global $path_to_root, $js_lib, $Validate, $Editors, $Ajax; + global $path_to_root, $js_lib, $Validate, $Editors, $Ajax, $sql_queries; include_once($path_to_root."/themes/".user_theme()."/renderer.php"); $rend = new renderer(); @@ -32,6 +32,12 @@ function page_footer($no_menu=false, $is_index=false, $hide_back_link=false) foreach($js_lib as $text) echo $text; echo "\n-->\n"; + + if ($sql_queries) { + div_start('footer_debug'); + echo "
$sql_queries
"; + div_end(); + } echo "\n"; }