From e966abc675d1a2c7877101a92b537f91bc77c68a Mon Sep 17 00:00:00 2001 From: David Durieux Date: Thu, 4 Apr 2024 14:56:30 +0200 Subject: [PATCH] Fix couple PHP notices --- inc/inventorycomputerlib.class.php | 47 ++++++++++++++++-------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/inc/inventorycomputerlib.class.php b/inc/inventorycomputerlib.class.php index 9ea02f60f..d772901d9 100644 --- a/inc/inventorycomputerlib.class.php +++ b/inc/inventorycomputerlib.class.php @@ -1499,33 +1499,36 @@ function updateComputer($a_computerinventory, $computers_id, $no_history, $setdy } if (count($db_crontasks) == 0) { - foreach ($a_computerinventory['crontasks'] as $a_crontask) { - if (isset($a_crontask['user_execution'])) { - $a_crontask['user_id_execution'] = $this->retrieveFusionInventoryCronTaskUserId($DB, $a_crontask['user_execution']); - } + if (isset($a_computerinventory['crontasks'])) { + foreach ($a_computerinventory['crontasks'] as $a_crontask) { + if (isset($a_crontask['user_execution'])) { + $a_crontask['user_id_execution'] = $this->retrieveFusionInventoryCronTaskUserId($DB, $a_crontask['user_execution']); + } - if (isset($a_crontask['user_storage'])) { - $a_crontask['user_id_storage'] = $this->retrieveFusionInventoryCronTaskUserId($DB, $a_crontask['user_storage']); - } + if (isset($a_crontask['user_storage'])) { + $a_crontask['user_id_storage'] = $this->retrieveFusionInventoryCronTaskUserId($DB, $a_crontask['user_storage']); + } - $a_crontask['computers_id'] = $computers_id; - $this->addFusionInventoryCronTask($a_crontask, $no_history); + $a_crontask['computers_id'] = $computers_id; + $this->addFusionInventoryCronTask($a_crontask, $no_history); + } } } else { - foreach ($a_computerinventory['crontasks'] as $key => $arrays) { - $arrayslower = array_map('strtolower', $arrays); - - foreach ($db_crontasks as $keydb => $arraydb) { - if ($arrayslower['name'] == $arraydb['name'] - && $arrayslower['storage'] == $arraydb['storage']) { - $arrays['id'] = $keydb; - $cronTask->update($arrays); - unset($a_computerinventory['crontasks'][$key]); - unset($db_crontasks[$keydb]); - break; + if (isset($a_computerinventory['crontasks'])) { + foreach ($a_computerinventory['crontasks'] as $key => $arrays) { + $arrayslower = array_map('strtolower', $arrays); + + foreach ($db_crontasks as $keydb => $arraydb) { + if ($arrayslower['name'] == $arraydb['name'] + && $arrayslower['storage'] == $arraydb['storage']) { + $arrays['id'] = $keydb; + $cronTask->update($arrays); + unset($a_computerinventory['crontasks'][$key]); + unset($db_crontasks[$keydb]); + break; + } } } - } //delete remaining crontasks in database if (count($db_crontasks) > 0) { @@ -1534,7 +1537,7 @@ function updateComputer($a_computerinventory, $computers_id, $no_history, $setdy } } //add new crontasks in database - if (count($a_computerinventory['crontasks']) != 0) { + if (isset($a_computerinventory['crontasks']) && count($a_computerinventory['crontasks']) != 0) { foreach ($a_computerinventory['crontasks'] as $a_crontask) { if (isset($a_crontask['user_execution'])) { $a_crontask['user_id_execution'] = $this->retrieveFusionInventoryCronTaskUserId($DB, $a_crontask['user_execution']);