Skip to content

Commit

Permalink
Fixing Issue #5609 - Improper XML File generate warning
Browse files Browse the repository at this point in the history
XML Bug when parsing Data Query XML Resource File when no field direction attribute is specified
  • Loading branch information
TheWitness committed Dec 8, 2023
1 parent 0529a37 commit d209b60
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ Cacti CHANGELOG
-issue#5589: When a graph has a real long cdef in graph debug mode, it forces an undesirable scroll
-issue#5590: Secondary LDAP server not evaluated when the first one has failed
-issue#5602: Missing "break" for case statement in cli/add_device.php
-issue#5609: XML Bug when parsing Data Query XML Resource File when no field direction attribute is specified
-feature#5577: Provide new templates for ArubaOS switch, Aruba wifi controller and HPE iLO to be available during install
-feature#5597: Provide new templates for Arubai OSCX 6x00 switch to be available during install

Expand Down
10 changes: 7 additions & 3 deletions lib/data_query.php
Original file line number Diff line number Diff line change
Expand Up @@ -2449,6 +2449,7 @@ function get_script_query_path($args, $script_path, $host_id) {
/**
* verify a given index_order
* @param array $raw_xml - parsed XML array
*
* @return bool - index_order field valid
*/
function verify_index_order($raw_xml) {
Expand All @@ -2463,13 +2464,16 @@ function verify_index_order($raw_xml) {

/* list each of the input fields for this snmp query */
foreach ($raw_xml['fields'] as $field_name => $field_array) {
if ($field_array['direction'] == 'input' || $field_array['direction'] == 'input-output') {
/* create a list of all values for this index */
array_push($xml_inputs, $field_name);
if (isset($field_array['direction'])) {
if ($field_array['direction'] == 'input' || $field_array['direction'] == 'input-output') {
/* create a list of all values for this index */
array_push($xml_inputs, $field_name);
}
}
}

This comment has been minimized.

Copy link
@xmacan

xmacan Dec 12, 2023

Member

@TheWitness
I suggest add else part. This could be useful when importing and finding problems with other templates
else {
cacti_log('Direction not found, maybe any issue with template');
}


$all_index_order_fields_found = true;

/* the xml file contains an ordered list of 'indexable' fields */
if (isset($raw_xml['index_order'])) {
$index_order_array = explode(':', $raw_xml['index_order']);
Expand Down

0 comments on commit d209b60

Please sign in to comment.