From 71fcb4fb9fc4687a82efab77c4bde9c20fc433e7 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Mon, 23 May 2022 17:29:41 +0200 Subject: [PATCH] fix error sql service pandora_enterprise#9018 --- pandora_console/include/lib/Module.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/lib/Module.php b/pandora_console/include/lib/Module.php index 382960b84b..d885e33d14 100644 --- a/pandora_console/include/lib/Module.php +++ b/pandora_console/include/lib/Module.php @@ -704,14 +704,19 @@ class Module extends Entity return false; } - return (bool) \db_process_sql_insert( - 'talert_template_modules', - [ - 'id_agent_module' => $this->id_agente_modulo(), - 'id_alert_template' => $id_alert_template, - 'last_reference' => time(), - ] - ); + $old = $this->alertTemplatesAssigned(); + if (in_array($id_alert_template, $old) === false) { + return (bool) \db_process_sql_insert( + 'talert_template_modules', + [ + 'id_agent_module' => $this->id_agente_modulo(), + 'id_alert_template' => $id_alert_template, + 'last_reference' => time(), + ] + ); + } + + return false; }