<?php
+
/**
* error.class.php
*
- * Copyright (c) 2005 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
* This contains the custom error handler for SquirrelMail.
*
+ * @copyright © 2005-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package squirrelmail
*/
/**
* Get current error reporting level.
*
- * PHP 4.1.2 does not return current error reporting level in ini_get (php 5.1b3 and
- * 4.3.10 does). Retrieve current error reporting level while setting error reporting
+ * PHP 4.1.2 does not return current error reporting level in ini_get (php 5.1b3 and
+ * 4.3.10 does). Retrieve current error reporting level while setting error reporting
* to ini value and reset it to retrieved value.
*/
$iCurErrLevel = error_reporting(ini_get('error_reporting'));
* (sq_mb_list_encodings(), ldap function calls in functions/abook_ldap_server.php)
* handle errors themselves and @ is used to disable generic php error messages.
*/
- if ((bool) $iCurErrLevel) {
+ if ($iErrNo & $iCurErrLevel) {
/*
* The following errors cannot be handled by a user defined error handler:
* E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING
/**
* Triggers an imap error. Utility function for sqm_trigger_error()
- * @param integer $iErrNo error number defined in errors.php
+ * @param string $sErrNo error string defined in errors.php
* @param string $sRequest imap request string
* @param string $sResponse tagged imap response
* @param string $sMessage tagged imap response message
* @author Marc Groot Koerkamp
* @since 1.5.1
*/
-function sqm_trigger_imap_error($iErrNo,$sRequest,$sResponse, $sMessage, $aExtra=array()) {
+function sqm_trigger_imap_error($sErrNo,$sRequest,$sResponse, $sMessage, $aExtra=array()) {
$aError = array(
'REQUEST' => $sRequest,
'RESPONSE' => $sResponse,
'MESSAGE' => $sMessage);
$aError = array_merge($aExtra,$aError);
- sqm_trigger_error($iErrNo,$aError);
+ sqm_trigger_error($sErrNo,$aError);
}
/**
* Trigger an error.
- * @param integer $iErrNo error number defined in errors.php
+ * @param string $sErrNo error string defined in errors.php
* @param array $aExtra optional associative array with extra error info
* @return void
* @author Marc Groot Koerkamp
* @since 1.5.1
*/
-function sqm_trigger_error($iErrNo,$aExtra=array()) {
- // Include the error definition file.
- include_once(SM_PATH.'include/errors.php');
+function sqm_trigger_error($sErrNo,$aExtra=array()) {
+ static $aErrors;
+ if (!isset($aErrors)) {
+ // Include the error definition file.
+ include_once(SM_PATH.'include/errors.php');
+ }
+
$iPhpErr = E_USER_NOTICE;
- if (is_array($aErrors) && isset($aErrors[$iErrNo]['level'])) {
+ if (is_array($aErrors) && isset($aErrors[$sErrNo]['level'])) {
if (is_array($aExtra) && count($aExtra)) {
- $aErrors[$iErrNo]['extra'] = $aExtra;
+ $aErrors[$sErrNo]['extra'] = $aExtra;
}
// because trigger_error can only handle a string argument for the error description
// we serialize the result.
- $sErrString = serialize($aErrors[$iErrNo]);
- $iPhpErr = $aErrors[$iErrNo]['level'];
+ $sErrString = serialize($aErrors[$sErrNo]);
+ $iPhpErr = $aErrors[$sErrNo]['level'];
} else {
- $sErrString = "Error number <$iErrNo> does not exist, fix the code or update the errors.php file";
+ sm_print_r($aErrors);
+ $sErrString = "Error <$sErrNo> does not exist, fix the code or update the errors.php file";
$iPhpErr = E_USER_ERROR;
}
trigger_error($sErrString, $iPhpErr);