glpi-project / glpi

GLPI is a Free Asset and IT Management Software package, Data center management, ITIL Service Desk, licenses tracking and software auditing.
https://glpi-project.org
GNU General Public License v3.0
4.36k stars 1.3k forks source link

Fix creating socket without item linked #18366

Closed cconard96 closed 1 week ago

cconard96 commented 1 week ago

Checklist before requesting a review

Description

Fixes #18202

Sockets are supposed to be allowed to exist without being connected to an item, but it was trying to save an empty string to the items_id column. Default selection for "Item" was an empty string instead of 0. Fix ensures that if the items_id field is an empty value, the itemtype and items_id values are not saved.

trasher commented 1 week ago

I've not been able to reproduce the initial issue. I've just created a Socket from the UI providing just a name; items_id was set to 0. From tests bootstrap data, it is set to null. Anyway, test do fail on current 10.0bugfixes branch without the fix, so it seems correct.