CRM-19670 Avoid loop when logging by only attempting to look up setting once
authoreileenmcnaugton <eileen@fuzion.co.nz>
Mon, 21 Nov 2016 00:33:05 +0000 (13:33 +1300)
committereileen <emcnaughton@wikimedia.org>
Sun, 5 Mar 2017 22:17:03 +0000 (11:17 +1300)
fix code style per Tim

CRM/Core/Error.php

index 81b470bbc0260adc65d70b8ffb018efc9a0210c4..1d2b465ca9e7139ce4627e05ac5b9eac6a5f0fe2 100644 (file)
@@ -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);