From 21ce4627ec2225184964869d69864f69a431401a Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Mon, 21 Nov 2016 13:33:05 +1300 Subject: [PATCH] CRM-19670 Avoid loop when logging by only attempting to look up setting once fix code style per Tim --- CRM/Core/Error.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php index 81b470bbc0..1d2b465ca9 100644 --- a/CRM/Core/Error.php +++ b/CRM/Core/Error.php @@ -605,7 +605,15 @@ class CRM_Core_Error extends PEAR_ErrorStack { } $file_log->close(); - if (!empty($config->userFrameworkLogging)) { + if (!isset(\Civi::$statics[__CLASS__]['userFrameworkLogging'])) { + // Set it to FALSE first & then try to set it. This is to prevent a loop as calling + // $config->userFrameworkLogging can trigger DB queries & under log mode this + // then gets called again. + \Civi::$statics[__CLASS__]['userFrameworkLogging'] = FALSE; + \Civi::$statics[__CLASS__]['userFrameworkLogging'] = $config->userFrameworkLogging; + } + + if (!empty(\Civi::$statics[__CLASS__]['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', array('%message' => $message), WATCHDOG_DEBUG); -- 2.25.1