Open g-bougard opened 2 months ago
To reproduce from tests suite:
diff --git a/tests/functional/Glpi/Inventory/Inventory.php b/tests/functional/Glpi/Inventory/Inventory.php
index 95c576353f..5ed5d1f78a 100644
--- a/tests/functional/Glpi/Inventory/Inventory.php
+++ b/tests/functional/Glpi/Inventory/Inventory.php
@@ -4931,7 +4931,7 @@ Compiled Tue 28-Sep-10 13:44 by prod_rel_team",
$services = [$mysql];
$json->content->databases_services = $services;
- $this->doInventory($json);
+ $inventory = $this->doInventory($json);
//check created databases & instances
$this->integer(countElementsInTable(\DatabaseInstance::getTable(), ['is_deleted' => 0]))->isIdenticalTo(1);
@@ -4951,6 +4951,17 @@ Compiled Tue 28-Sep-10 13:44 by prod_rel_team",
$this->array(array_pop($databases))
->string['name']->isIdenticalTo('glpi')
->integer['size']->isIdenticalTo(55000);
+
+ $computer = new \Computer();
+ global $DB;
+ $agents = $DB->request(['FROM' => \Agent::getTable()]);
+ $this->integer(count($agents))->isIdenticalTo(1);
+ $agent = $agents->current();
+ $computers_id = $agent['items_id'];
+ $this->boolean($computer->getFromDB($computers_id))->isTrue();
+ $this->boolean($computer->delete(['id' => $computers_id], true))->isTrue();
}
I've not been able to find how to fix. To me, removing data in Computer::pre_deleteItem()
should have done the trick, but it did not.
When creating a databse instance from the UI, without selecting any Item type
/Item
, the itemtype
value stored in DB is 0
. It whould probably be null in this case. Anyway, the problem is that this field is not nullable, but it should probably be nullable, as the value is not mandatory.
Not sure null is a correct solution. Having database instance back from inventory would probably create a new record; in that case, it may be better to remove instance when attached computer is purged. That kind of case must probably be added in tests so we know hos it works.
Code of Conduct
Is there an existing issue for this?
Version
10.0.15
Bug description
I was able to delete a computer from assets without any error but I found later in sql-errors.log a SQL error. I don't think massive action context is relevant.
Relevant log output
Page URL
No response
Steps To reproduce
Your GLPI setup information
Informations sur le système, l'installation et la configuration
Server
GLPI constants
Libraries
SQL replicas
Notifications
Plugins list
Anything else?
No response