Skip to content

Commit

Permalink
Fixing Issue #4551 - PHP 8.1 Deprecation Errors
Browse files Browse the repository at this point in the history
Thanks for this one.  See if you can find more.  Let me know that these are fixed too of course.
  • Loading branch information
TheWitness committed Feb 12, 2022
1 parent f26793d commit 3192842
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Cacti CHANGELOG
-issue#4546: Instead of receiving a permission denied message unauthenticated issues were redirected
-issue#4547: Testing with LDAP authentication generating backtraces
-issue#4548: CMDPHP PHP ERROR Backtrace and other errors
-issue#4551: PHP DEPRECATED errors in 8.1
-feature: Expose hidden Language Translation setting l10n_language_handler
-feature: Allow a Device to be a part of a Report outside of a Tree
-feature: Allow Basic Authentication to display customer login failed message
Expand Down
10 changes: 8 additions & 2 deletions lib/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function import_xml_data(&$xml_data, $import_as_new, $profile_id, $remove_orphan
if (isset($dep_hash_cache[$type])) {
/* yes we do. loop through each match for this type */
for ($i=0; $i<cacti_count($dep_hash_cache[$type]); $i++) {
$import_debug_info = false;
$import_debug_info = array();

if (!isset($cacti_version_codes[$dep_hash_cache[$type][$i]['version']])) {
return false;
Expand Down Expand Up @@ -223,7 +223,7 @@ function import_xml_data(&$xml_data, $import_as_new, $profile_id, $remove_orphan
break;
}

if (!empty($import_debug_info)) {
if (!cacti_sizeof($import_debug_info)) {
$info_array[$type][isset($info_array[$type]) ? cacti_count($info_array[$type]) : 0] = $import_debug_info;
}
}
Expand Down Expand Up @@ -661,14 +661,17 @@ function xml_to_graph_template($hash, &$xml_array, &$hash_cache, $hash_version,

if (isset($new_items) && cacti_sizeof($new_items)) {
$new_text = array();

foreach($new_items as $item) {
$new_text[] = 'New Graph Items, Type: ' . $graph_item_types[$item['graph_type_id']] . ', Text Format: ' . $item['text_format'] . ', Value: ' . $item['value'];
}

$import_debug_info['new_items'] = $new_text;
}

if (isset($orphaned_items) && cacti_sizeof($orphaned_items)) {
$orphan_text = array();

foreach($orphaned_items as $item) {
if ($remove_orphans) {
$orphan_text[] = 'Removed Orphaned Graph Items, Type: ' . $graph_item_types[$item['graph_type_id']] . ', Text Format: ' . $item['text_format'] . ', Value: ' . $item['value'];
Expand All @@ -684,6 +687,7 @@ function xml_to_graph_template($hash, &$xml_array, &$hash_cache, $hash_version,
$orphan_text[] = 'Found Orphaned Graph Items, Type: ' . $graph_item_types[$item['graph_type_id']] . ', Text Format: ' . $item['text_format'] . ', Value: ' . $item['value'];
}
}

$import_debug_info['orphans'] = $orphan_text;

if ($remove_orphans) {
Expand Down Expand Up @@ -1865,6 +1869,7 @@ function compare_data($save, $previous_data, $table) {
}

$different++;

$import_debug_info['differences'][] = 'Table: ' . $table . ', Column: ' . $column . ', New Value: ' . $newvalue . ', Old Value: ' . $oldvalue;
}
}
Expand Down Expand Up @@ -1971,6 +1976,7 @@ function resolve_hash_to_id($hash, &$hash_cache_array) {

if (isset($hash_cache_array[$parsed_hash['type']][$parsed_hash['hash']])) {
$import_debug_info['dep'][$hash] = 'met';

return $hash_cache_array[$parsed_hash['type']][$parsed_hash['hash']];
} else {
/* bad snmp port hashes */
Expand Down
2 changes: 1 addition & 1 deletion lib/rrd.php
Original file line number Diff line number Diff line change
Expand Up @@ -1903,7 +1903,7 @@ function rrdtool_function_graph($local_graph_id, $rra_id, $graph_data_array, $rr
if (isset($graph_item['local_data_id'])) {
$cdef_string = str_replace('SIMILAR_DATA_SOURCES_NODUPS_PI', db_fetch_cell_prepared('SELECT rrd_step FROM data_template_data WHERE local_data_id = ?', array($graph_item['local_data_id'])), $cdef_string);
} else {
$cdef_string = str_replace('SIMILAR_DATA_SOURCES_NODUPS_PI', read_config_option('poller_id'), $cdef_string);
$cdef_string = str_replace('SIMILAR_DATA_SOURCES_NODUPS_PI', read_config_option('poller_interval'), $cdef_string);
}

if (isset($magic_item['SIMILAR_DATA_SOURCES_NODUPS'])) {
Expand Down

0 comments on commit 3192842

Please sign in to comment.