Skip to content

Commit

Permalink
fix(replace): error with infocom (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rom1-B authored Jun 10, 2024
1 parent cee3c8e commit 9999b05
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions inc/replace.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,19 @@ public static function replace($type, $model_id, $tab_ids, $location)
}
}

// Update current Infocoms of old item
if ($infocom->getFromDBforDevice($type, $olditem_id)) {
$infocom->update(
['id' => $infocom->getID(),
'itemtype' => $type,
'items_id' => $newitem_id
],
false
);
// Checks that the itemtype/items_id key doesn't already exist to avoid duplication
if (!$infocom->getFromDBforDevice($type, $newitem_id)) {
// Update current Infocoms of old item
if ($infocom->getFromDBforDevice($type, $olditem_id)) {
$infocom->update(
[
'id' => $infocom->getID(),
'itemtype' => $type,
'items_id' => $newitem_id
],
false
);
}
}
}

Expand Down Expand Up @@ -932,8 +936,7 @@ public static function getAssociatedContracts(CommonDBTM $item)
'WHERE' => [
'glpi_contracts_items.items_id' => $item->getField('id'),
'glpi_contracts_items.itemtype' => $item->getType(),
getEntitiesRestrictCriteria('glpi_contracts', '', '', true)
]
] + getEntitiesRestrictCriteria('glpi_contracts', '', '', true)
];
$it = $DB->request($criteria);
foreach ($it as $data) {
Expand Down Expand Up @@ -974,8 +977,7 @@ public static function getAssociatedTickets($itemtype, $items_id)
'WHERE' => [
'itemtype' => $itemtype,
'items_id' => $items_id,
getEntitiesRestrictCriteria('glpi_tickets')
]
] + getEntitiesRestrictCriteria('glpi_tickets')
]);
foreach ($it as $data) {
$tickets[] = $data;
Expand Down

0 comments on commit 9999b05

Please sign in to comment.