From: cajus Date: Wed, 18 May 2005 12:54:03 +0000 (+0000) Subject: Improved error handling. This will be enhanced later on X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=23c6115c65a63970b01c54675c20afc99e8110a0;p=gosa.git Improved error handling. This will be enhanced later on git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@243 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/html/main.php b/html/main.php index d1a764427..cd8cfa3da 100644 --- a/html/main.php +++ b/html/main.php @@ -18,21 +18,16 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* This will be removed... */ -function raiseError($errno, $errstr, $errfile, $errline) -{ - gosa_log ("PHP error: $errstr ($errfile, line $errline)"); -} - -#set_error_handler('raiseError'); -/* This will be removed */ - /* Basic setup, remove eventually registered sessions */ $timing= array(); require_once ("../include/php_setup.inc"); require_once ("functions.inc"); header("Content-type: text/html; charset=UTF-8"); +/* Reset error handler */ +$error_collector= ""; +set_error_handler('gosaRaiseError'); + /* Find all class files and include them */ get_dir_list("$BASE_DIR/plugins"); @@ -88,6 +83,9 @@ setlocale(LC_ALL, $lang); $GLOBALS['t_language']= $lang; $GLOBALS['t_gettext_message_dir'] = $BASE_DIR.'/locale/'; +/* Dummy */ +trigger_error("I'm a fake error. Please ignore me.", E_USER_NOTICE); + /* Set the text domain as 'messages' */ $domain = 'messages'; bindtextdomain($domain, "$BASE_DIR/locale"); @@ -273,6 +271,7 @@ $smarty->assign("contents", $display); if (isset($_SESSION['errors'])){ $smarty->assign("errors", $_SESSION['errors']); } +$smarty->assign("php_errors", $error_collector); $smarty->display(get_template_path('framework.tpl')); $_SESSION['plist']= $plist; diff --git a/ihtml/themes/default/framework.tpl b/ihtml/themes/default/framework.tpl index 389eb96e4..e7337090f 100644 --- a/ihtml/themes/default/framework.tpl +++ b/ihtml/themes/default/framework.tpl @@ -1,5 +1,6 @@ +{$php_errors}
diff --git a/include/class_mail-methods-cyrus.inc b/include/class_mail-methods-cyrus.inc index b49720074..2c5c532cb 100644 --- a/include/class_mail-methods-cyrus.inc +++ b/include/class_mail-methods-cyrus.inc @@ -18,10 +18,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -function fake_handler($log_level, $log_text, $error_file, $error_line) -{ -} - class mailMethodCyrus extends mailMethod { var $mbox= "-"; @@ -40,9 +36,7 @@ class mailMethodCyrus extends mailMethod $cfg= $this->config[$gosaMailServer]; /* For some reason, hiding errors with @ does not wor here... */ - $tmp= set_error_handler('fake_handler'); $this->mbox = @imap_open($cfg['connect'], $cfg['admin'], $cfg['password'], OP_HALFOPEN); - set_error_handler($tmp); /* Mailbox reachable? */ if ($this->mbox === FALSE){ diff --git a/include/functions.inc b/include/functions.inc index bf46a15c0..d802662ff 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -1509,5 +1509,14 @@ function get_gosa_version() } } +function gosaRaiseError($errno, $errstr, $errfile, $errline) +{ + global $error_collector; + + $error_collector.= "PHP error: $errstr ($errfile, line $errline)
"; + $error_collector.= sprintf(_("File %s, line %s: %s"), $errfile, $errline, $errstr)."
"; + gosa_log ("PHP error: $errstr ($errfile, line $errline)"); +} + // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/include/php_setup.inc b/include/php_setup.inc index e74f4eebe..4fdccbc2d 100644 --- a/include/php_setup.inc +++ b/include/php_setup.inc @@ -27,7 +27,7 @@ $variables_order= "ES"; ini_set("register_globals",0); ini_set("track_vars",1); ini_set("include_path",".:$BASE_DIR/include"); -#ini_set("display_errors",0); +ini_set("display_errors",0); /* Do smarty setup */ require("smarty/Smarty.class.php");