Code Monkey home page Code Monkey logo

Comments (3)

trasher avatar trasher commented on June 20, 2024

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.

from glpi.

cedric-anne avatar cedric-anne commented on June 20, 2024

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.

from glpi.

trasher avatar trasher commented on June 20, 2024

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.

from glpi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.