X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FError.php;h=bac07e05d3e8d1197b51d43f08df7b2845954692;hb=225584c91fea180fc9e06c9171f08b7f222ebac1;hp=c82568b745c943cc95f07b2f0e7765bdf9a16296;hpb=725b3de6f03330ab5e310f397fc0336fe551ec6f;p=civicrm-core.git diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php index c82568b745..bac07e05d3 100644 --- a/CRM/Core/Error.php +++ b/CRM/Core/Error.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.6 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2014 | + | Copyright CiviCRM LLC (c) 2004-2015 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -30,7 +30,7 @@ * PEAR_ErrorStack and use that framework * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2014 + * @copyright CiviCRM LLC (c) 2004-2015 * $Id$ * */ @@ -192,7 +192,16 @@ class CRM_Core_Error extends PEAR_ErrorStack { $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(); @@ -201,13 +210,9 @@ class CRM_Core_Error extends PEAR_ErrorStack { // 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; @@ -587,7 +592,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { 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); } } @@ -649,7 +654,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { ($fileSize < 0) ) { rename($fileName, - $fileName . '.' . date('Ymdhs', mktime(0, 0, 0, date("m") - 1, date("d"), date("Y"))) + $fileName . '.' . date('YmdHi') ); } }