From b3a212251e36f810345d9b0d54e3dd359ac2f830 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 30 Apr 2024 13:29:07 +0200 Subject: [PATCH] #13501 no show error when update without change anything --- .../godmode/agentes/configurar_agente.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index cdbe26d89d..01688effaa 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -1065,6 +1065,7 @@ if ($update_agent) { } $field_values = []; + $update_custom_result = false; foreach ($fields as $field) { $field_value = get_parameter_post('customvalue_'.$field['id_field'], ''); @@ -1115,7 +1116,7 @@ if ($update_agent) { ); if ($update_custom == 1) { - $update_custom_result = 1; + $update_custom_result = true; } } } @@ -1157,6 +1158,7 @@ if ($update_agent) { } } + $agent_data = agents_get_agent($id_agente); $values = [ 'disabled' => $disabled, 'id_parent' => $id_parent, @@ -1184,6 +1186,14 @@ if ($update_agent) { 'vul_scan_enabled' => $vul_scan_enabled, 'ignore_unknown' => $ignore_unknown, ]; + // Update change fix on ticket 13501 to no show errors when press button update with out change anything. + $update_change = false; + foreach ($values as $key => $value) { + if (isset($agent_data[$key]) === true && $agent_data[$key] !== $value) { + $update_agent = true; + break; + } + } if (empty($repeated_name) === true) { $values['nombre'] = $nombre_agente; @@ -1195,7 +1205,7 @@ if ($update_agent) { } $result = (bool) db_process_sql_update('tagente', $values, ['id_agente' => $id_agente]); - if ($result === false && $update_custom_result == false) { + if ($result === false && $update_custom_result === false && $update_change === true) { ui_print_error_message( __('There was a problem updating the agent') );