From 1ae91e72817789a8b31b5a294e920574cd4488ed Mon Sep 17 00:00:00 2001 From: Esteban Sanchez Date: Wed, 5 Nov 2008 13:12:45 +0000 Subject: [PATCH] 2009-11-05 Esteban Sanchez * include/functions_db.php: Added sql_error_handler() to show SQL errors. Improved SQL error messages in process_sql() so it shows now the failing sentence, the file and the line of the call. * index.php: Moved load_extensions() call after enterprise instalation so enterprise extensions are installed properly. * godmode/profiles/profile_list.php: HTML tags nesting fixed. * ChangeLog: Fixed previous commit message style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1219 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 47 ++++++++++++------- .../godmode/profiles/profile_list.php | 2 +- pandora_console/include/functions_db.php | 18 ++++++- pandora_console/index.php | 8 ++-- 4 files changed, 52 insertions(+), 23 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a96ca3692d..f5a7d6bb03 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2009-11-05 Esteban Sanchez + + * include/functions_db.php: Added sql_error_handler() to show SQL + errors. Improved SQL error messages in process_sql() so it shows now + the failing sentence, the file and the line of the call. + + * index.php: Moved load_extensions() call after enterprise + instalation so enterprise extensions are installed properly. + + * godmode/profiles/profile_list.php: HTML tags nesting fixed. + + * ChangeLog: Fixed previous commit message style. + 2008-11-05 Ramon Novoa * pandoradb.sql: Deleted 'id_inventory_server' column from 'tagente' @@ -6,27 +19,27 @@ 2009-11-05 Jorge Gonzalez * include/languages/pt_BR.mo, include/languages/fr.po, - include/languages/uk.mo, include/languages/ro.mo, - include/languages/ca.po, include/languages/sv.po, - include/languages/de.po, include/languages/zh_TW.po, - include/languages/hi.po, include/languages/zh_CN.po, - include/languages/fr.mo, include/languages/te.po, - include/languages/eu.po, include/languages/hu.po, - include/languages/ca.mo, include/languages/de.mo, - include/languages/sv.mo, include/languages/ru.po, - include/languages/zh_TW.mo, include/languages/hi.mo, - include/languages/zh_CN.mo, include/languages/gl.po, - include/languages/te.mo, include/languages/eu.mo, - include/languages/hu.mo, include/languages/pl.po, - include/languages/it.po, include/languages/sl.po, - include/languages/ru.mo, include/languages/pt.po, - include/languages/ast.po, include/languages/gl.mo: Updated - translations from rosetta: thanks to all contributors. + include/languages/uk.mo, include/languages/ro.mo, + include/languages/ca.po, include/languages/sv.po, + include/languages/de.po, include/languages/zh_TW.po, + include/languages/hi.po, include/languages/zh_CN.po, + include/languages/fr.mo, include/languages/te.po, + include/languages/eu.po, include/languages/hu.po, + include/languages/ca.mo, include/languages/de.mo, + include/languages/sv.mo, include/languages/ru.po, + include/languages/zh_TW.mo, include/languages/hi.mo, + include/languages/zh_CN.mo, include/languages/gl.po, + include/languages/te.mo, include/languages/eu.mo, + include/languages/hu.mo, include/languages/pl.po, + include/languages/it.po, include/languages/sl.po, + include/languages/ru.mo, include/languages/pt.po, + include/languages/ast.po, include/languages/gl.mo: Updated + translations from rosetta: thanks to all contributors. 2008-11-04 Jorge Gonzalez * include/languages/es.po, include/languages/es.mo: Updated Spanish - translation. + translation. 2008-10-31 Ramon Novoa diff --git a/pandora_console/godmode/profiles/profile_list.php b/pandora_console/godmode/profiles/profile_list.php index 936c02703e..479fa44578 100644 --- a/pandora_console/godmode/profiles/profile_list.php +++ b/pandora_console/godmode/profiles/profile_list.php @@ -281,7 +281,7 @@ if ($id_profile || $new_profile) { echo '
'; print_input_hidden ('new_profile', 1); print_submit_button (__('Create profile'), "crt", false, 'class="sub next"'); - echo ''; echo "
"; + echo ''; } ?> diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 058ab82845..50d3a916c1 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -1424,6 +1424,17 @@ function get_db_all_rows_sql ($sql) { return false; } +/** + * Error handler function when an SQL error is triggered. + * + * @param $errno Level of the error raised (not used, but required by set_error_handler()). + * @param $errstr Contains the error message. + */ +function sql_error_handler ($errno, $errstr) { + echo "SQL error: ".$errstr."
\n"; + return true; +} + /** * This function comes back with an array in case of SELECT * in case of UPDATE, DELETE etc. with affected rows @@ -1450,7 +1461,12 @@ function process_sql ($sql, $rettype = "affected_rows") { } else { $result = mysql_query ($sql); if ($result === false) { - trigger_error (mysql_error ()); + $backtrace = debug_backtrace (); + $error = sprintf ('%s (\'%s\') in %s on line %d', + mysql_error (), $sql, $backtrace[0]['file'], $backtrace[0]['line']); + set_error_handler ('sql_error_handler'); + trigger_error ($error); + restore_error_handler (); return false; } elseif ($result === true) { if ($rettype == "insert_id") { diff --git a/pandora_console/index.php b/pandora_console/index.php index c02fb81c70..67d76dab61 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -63,14 +63,14 @@ session_start(); require_once ("include/config.php"); require_once ("include/functions.php"); require_once ("include/functions_db.php"); -//We should require this or you might end up with some empty strings -load_extensions ($config['extensions']); /* Enterprise support */ -if (file_exists ("enterprise/load_enterprise.php")) { - include ("enterprise/load_enterprise.php"); +if (file_exists (ENTERPRISE_DIR."/load_enterprise.php")) { + include (ENTERPRISE_DIR."/load_enterprise.php"); } +load_extensions ($config['extensions']); + echo ''; // Pure mode (without menu, header and footer).