Merge branch '2677-No-se-elimina-parent-id-entre-modulos-del-mismo-agente' into 'develop'

Fixed bug in modules deletion: parent id set to 0 in case parent has been deleted

See merge request artica/pandorafms!1727
This commit is contained in:
vgilc 2018-10-25 10:37:11 +02:00
commit ea0474e704

View File

@ -292,12 +292,22 @@ sub pandora_purgedb ($$) {
# Delete pending modules
log_message ('PURGE', "Deleting pending delete modules (data table).", '');
my @deleted_modules = get_db_rows ($dbh, 'SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 1');
my @all_modules = get_db_rows ($dbh, 'SELECT id_agente_modulo, parent_module_id FROM tagente_modulo');
foreach my $module (@deleted_modules) {
my $buffer = 1000;
my $id_module = $module->{'id_agente_modulo'};
foreach my $m (@all_modules) {
my $id_parent = $m->{'parent_module_id'};
my $id_module_fetched = $m->{'id_agente_modulo'};
if ($id_parent == $id_module) {
db_do ($dbh, 'UPDATE tagente_modulo SET parent_module_id=0 WHERE id_agente_modulo=?', $id_module_fetched);
}
}
log_message ('', ".");
while(1) {