diff --git a/CHANGELOG b/CHANGELOG index 9911be041..4c882bdee 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -76,6 +76,7 @@ Cacti CHANGELOG -issue#5459: There is no option to not duplicate Graph Template Data Query association when duplicating a Graph Template -issue#5460: When duplicating a Data Template errors can appear in the Cacti log -issue#5462: Package preview aparantely making changes to Cacti Templates or there is a Caching issue +-issue#5467: Cacti logging throws error when attempting to generate a log message from empty log string in PHP 8.x -feature#5375: Add template for Fortinet firewall and Aruba Instant cluster -feature#5393: Add template for SNMP printer -feature#5418: Display device class before package import diff --git a/lib/functions.php b/lib/functions.php index e660dd37d..2e72fb355 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -210,7 +210,7 @@ function set_user_setting($config_name, $value, $user = -1) { if (strlen($config_name) > 75) { cacti_log("ERROR: User setting name '$config_name' is too long, will be truncated", false, 'SYSTEM'); } - + db_execute_prepared('REPLACE INTO settings_user SET user_id = ?, name = ?, @@ -1280,6 +1280,10 @@ function cacti_log($string, $output = false, $environ = 'CMDPHP', $level = '') { $database_log = false; } + if (trim($string) == '') { + return false; + } + $last_log = $database_log; $database_log = false; $force_level = get_selective_log_level(); @@ -5086,8 +5090,13 @@ function mailer($from, $to, $cc, $bcc, $replyto, $subject, $body, $body_text = ' } cacti_log($message, false, 'MAILER'); + if ($result == false) { - cacti_log(cacti_debug_backtrace($rtype), false, 'MAILER'); + $backtrace = trim(cacti_debug_backtrace($rtype)); + + if ($backtrace != '') { + cacti_log($backtrace, false, 'MAILER'); + } } return $error; @@ -7337,4 +7346,4 @@ function cacti_unserialize($strobj) { } else { return unserialize($strobj); } -} \ No newline at end of file +}