From 80cdbe0bb29908115a70d116cab646d6a2b24c10 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Wed, 24 Aug 2016 07:46:19 +1000 Subject: [PATCH] Backport fix for CRM-13640 to 4.6 --- CRM/Core/Error.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php index 4aef6605c0..cca09a832c 100644 --- a/CRM/Core/Error.php +++ b/CRM/Core/Error.php @@ -630,6 +630,23 @@ class CRM_Core_Error extends PEAR_ErrorStack { CRM_Core_Error::debug_var('dao result', array('query' => $query, 'results' => $results)); } + /** + * Generate a hash for the logfile. + * CRM-13640. + */ + protected static function generateLogFileHash($config) { + // Use multiple (but stable) inputs for hash information. TMI? + $md5inputs = array( + defined('CIVICRM_SITE_KEY') ? CIVICRM_SITE_KEY : 'NO_SITE_KEY', + $config->userFrameworkBaseURL, + md5($config->dsn), + $config->dsn, + ); + // Trim 8 chars off the string, make it slightly easier to find + // but reveals less information from the hash. + return substr(md5(var_export($md5inputs, 1)), 8); + } + /** * Obtain a reference to the error log. * @@ -643,8 +660,8 @@ class CRM_Core_Error extends PEAR_ErrorStack { if ($comp) { $comp = $comp . '.'; } - - $fileName = "{$config->configAndLogDir}CiviCRM." . $comp . md5($config->dsn) . '.log'; + $hash = self::generateLogFileHash($config); + $fileName = "{$config->configAndLogDir}CiviCRM." . $comp . $hash . '.log'; // Roll log file monthly or if greater than 256M // note that PHP file functions have a limit of 2G and hence -- 2.25.1