ocsinventoryng icon indicating copy to clipboard operation
ocsinventoryng copied to clipboard

Force full import delete software if it is installed once.

Open fgendorf opened this issue 6 years ago • 0 comments

Hi, when I force synchronization of a computer, if software there are one version, the software is deleted and recreated again and all information about this software is lost, doesn't matter if the software was licenses, attributes, etc

file: plugins/ocsinventoryng/inc/software.class.php lines: 484:495

$query3  = "SELECT COUNT(*)
                          FROM `glpi_softwareversions`
                          WHERE `softwares_id`= " . $vers->fields['softwares_id'];
               $result3 = $DB->query($query3);

               if ($DB->result($result3, 0, 0) == 1) {
                  $soft = new Software();
                  $soft->delete(['id'          => $vers->fields['softwares_id'],
                                 '_no_history' => !$uninstall_history],
                                true,
                                $uninstall_history);
               }

maybe check if software have attributes like category changed

$query3  = "SELECT glpi.glpi_softwares.softwarecategories_id 
                          FROM `glpi_softwareversions`
                          INNER JOIN glpi.glpi_softwares ON (glpi_softwareversions.softwares_id = glpi_softwares.id )
                          WHERE glpi_softwareversions.`softwares_id`='{$vers->fields['softwares_id']}'
                          LIMIT 1";
               $result3 = $DB->query($query3);

               if ($DB->result($result3, 0, 0) == 0) {
                  $soft = new Software();
                  $soft->delete(['id'          => $vers->fields['softwares_id'],
                                 '_no_history' => !$uninstall_history],
                                true,
                                $uninstall_history);
               }
  • The version of the plugin. 1.6.0

  • The version of your GLPI. 9.4.3

  • The steps to reproduce your issue. leave one software installed only on a unique computer, force sync of the computer, the software will be deleted and created again, all information of software will be lost

fgendorf avatar Sep 18 '19 11:09 fgendorf