class CRM_Core_Error extends PEAR_ErrorStack {
/**
- * Status code of various types of errors
+ * Status code of various types of errors.
*/
const FATAL_ERROR = 2;
const DUPLICATE_CONTACT = 8001;
private static $_singleton = NULL;
/**
- * The logger object for this application
+ * The logger object for this application.
* @var object
*/
private static $_log = NULL;
}
/**
- * Constructor
+ * Constructor.
*/
public function __construct() {
parent::__construct('CiviCRM');
}
/**
- * Status display function specific to payment processor errors
+ * Status display function specific to payment processor errors.
* @param $error
* @param string $separator
*/
$error['type'] = $pearError->getType();
$error['user_info'] = $pearError->getUserInfo();
$error['to_string'] = $pearError->toString();
- if (function_exists('mysql_error') &&
+
+ // We access connection info via _DB_DATAOBJECT instead
+ // of, e.g., calling getDatabaseConnection(), so that we
+ // can avoid infinite loops.
+ global $_DB_DATAOBJECT;
+
+ if (!isset($_DB_DATAOBJECT['CONFIG']['database'])) {
+ // we haven't setup sql, so it's not our sql error...
+ }
+ elseif (preg_match('/^mysql:/', $_DB_DATAOBJECT['CONFIG']['database']) &&
mysql_error()
) {
$mysql_error = mysql_error() . ', ' . mysql_errno();
// execute a dummy query to clear error stack
mysql_query('select 1');
}
- elseif (function_exists('mysqli_error')) {
+ elseif (preg_match('/^mysqli:/', $_DB_DATAOBJECT['CONFIG']['database'])) {
$dao = new CRM_Core_DAO();
- // we do it this way, since calling the function
- // getDatabaseConnection could potentially result
- // in an infinite loop
- global $_DB_DATAOBJECT;
if (isset($_DB_DATAOBJECT['CONNECTIONS'][$dao->_database_dsn_md5])) {
$conn = $_DB_DATAOBJECT['CONNECTIONS'][$dao->_database_dsn_md5];
$link = $conn->connection;
}
/**
- * Display an error page with an error message describing what happened
+ * Display an error page with an error message describing what happened.
*
* @param string $message
* The error message.
}
/**
- * Display an error page with an error message describing what happened
+ * Display an error page with an error message describing what happened.
*
* This function is evil -- it largely replicates fatal(). Hopefully the
* entire CRM_Core_Error system can be hollowed out and replaced with
}
/**
- * Display the error message on terminal
+ * Display the error message on terminal.
*
* @param $message
* @param bool $out
if ($config->userFrameworkLogging) {
// should call $config->userSystem->logger($message) here - but I got a situation where userSystem was not an object - not sure why
if ($config->userSystem->is_drupal and function_exists('watchdog')) {
- watchdog('civicrm', $message, NULL, WATCHDOG_DEBUG);
+ watchdog('civicrm', '%message', array('%message' => $message), WATCHDOG_DEBUG);
}
}
}
/**
- * Obtain a reference to the error log
+ * Obtain a reference to the error log.
*
* @param string $comp
*
}
/**
- * Render a backtrace array as a string
+ * Render a backtrace array as a string.
*
* @param array $backTrace
* Array of stack frames.
}
/**
- * Render a backtrace array as an array
+ * Render a backtrace array as an array.
*
* @param array $backTrace
* Array of stack frames.
}
/**
- * Render an exception as HTML string
+ * Render an exception as HTML string.
*
* @param Exception $e
* @return string
}
/**
- * Write details of an exception to the log
+ * Write details of an exception to the log.
*
* @param Exception $e
* @return string
}
/**
- * Reset the error stack
+ * Reset the error stack.
*
*/
public static function reset() {
}
/**
- * Terminate execution abnormally
+ * Terminate execution abnormally.
*/
protected static function abend($code) {
// do a hard rollback of any pending transactions