Skip to content

Commit

Permalink
Fixing #5467 - Cacti Log issues in certain circumstances
Browse files Browse the repository at this point in the history
Cacti logging throws error when attempting to generate a log message from empty log string in PHP 8.x
  • Loading branch information
TheWitness committed Aug 24, 2023
1 parent f09a9dc commit 5285686
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions lib/functions.php
Expand Up @@ -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 = ?,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -7337,4 +7346,4 @@ function cacti_unserialize($strobj) {
} else {
return unserialize($strobj);
}
}
}

0 comments on commit 5285686

Please sign in to comment.