pluginsGLPI / ocsinventoryng

Plugin ocsinventoryng for GLPI
GNU General Public License v2.0
68 stars 52 forks source link

Bitlocker SQL error - Column 'item_disks_id' cannot be null #302

Open blippercop opened 2 years ago

blippercop commented 2 years ago

Dear GLPi user.

For bug reports, you can open an issue here, provide us :

[2022-01-17 16:00:22] glpisqllog.ERROR: DBmysql::query() in /var/www/helpdesk/inc/dbmysql.class.php line 309
 *** MySQL query error:
 SQL: INSERT INTO `glpi_plugin_ocsinventoryng_bitlockerstatuses` (`computers_id`, `item_disks_id`, `volume_type`, `protection_status`, `init_project`) VALUES ('792', NULL, '', 'ENABLED', '')
 Error: Column 'item_disks_id' cannot be null
 Backtrace :
 inc/dbmysql.class.php:1148                         
 inc/commondbtm.class.php:605                       DBmysql->insert()
 inc/commondbtm.class.php:1169                      CommonDBTM->addToDB()
 ...csinventoryng/inc/bitlockerstatus.class.php:107 CommonDBTM->add()
 plugins/ocsinventoryng/inc/disk.class.php:178      PluginOcsinventoryngBitlockerstatus::updateBitlocker()
 ...ns/ocsinventoryng/inc/ocsprocess.class.php:1313 PluginOcsinventoryngDisk::updateDisk()
 ...ins/ocsinventoryng/inc/ocsprocess.class.php:474 PluginOcsinventoryngOcsProcess::synchronizeComputer()
 ...s/ocsinventoryng/scripts/ocsng_fullsync.php:417 PluginOcsinventoryngOcsProcess::processComputer()
 ...s/ocsinventoryng/scripts/ocsng_fullsync.php:293 plugin_ocsinventoryng_importFromOcsServer()
 ...s/ocsinventoryng/scripts/ocsng_fullsync.php:179 SecondPass()
blippercop commented 2 years ago

Reference: https://github.com/pluginsGLPI/ocsinventoryng/issues/262 Still open issue.

blippercop commented 2 years ago

PHP Notice: Undefined index: DISABLED in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 91 PHP Notice: Undefined index: id in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 99 .PHP Notice: Undefined index: id in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 78 PHP Notice: Undefined index: ENABLED in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 91 PHP Notice: Undefined index: id in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 99 .PHP Notice: Undefined index: id in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 78 PHP Notice: Undefined index: ENABLED in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 91 PHP Notice: Undefined index: id in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 99 .PHP Notice: Undefined index: id in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 78 PHP Notice: Undefined index: ENABLED in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 91 PHP Notice: Undefined index: id in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 99 PHP Notice: Undefined index: id in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 78 ..PHP Notice: Undefined index: id in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 78 PHP Notice: Undefined index: ENABLED in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 91 PHP Notice: Undefined index: id in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 99 .PHP Notice: Undefined index: id in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 78 PHP Notice: Undefined index: id in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 78 PHP Notice: Undefined index: DISABLED in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 91 PHP Notice: Undefined index: id in /var/www/helpdesk/plugins/ocsinventoryng/inc/bitlockerstatus.class.php on line 99

blippercop commented 2 years ago

...csinventoryng/inc/bitlockerstatus.class.php:107 CommonDBTM->add() -> static function updateBitlocker($computers_id, $ocsBitlockerStatus, $disk, $cfg_ocs, $force = 0) { --> this function gets a $disk object like this: image ---> HOWEVER in the disk.class.php you can find this line: $inputBitlockers["item_disks_id"] = $disk['id']; ----> there is no $disk['id'] when the issue occurs -----> so the $disk['id'] is only set under the condition from it IF block but if the IF is not executed there will be no $disk['id'] but it will still be handed to bitlocker update function

 // Update on type, total size change or variation of 5%
                        if ($d->fields['totalsize'] != $disk['totalsize']
                            || ($d->fields['filesystems_id'] != $disk['filesystems_id'])
                            || ((abs($disk['freesize'] - $d->fields['freesize']) / $disk['totalsize']) > 0.05)
                        ) {

                           $toupdate['id']             = $id;
                           $toupdate['totalsize']      = $disk['totalsize'];
                           $toupdate['freesize']       = $disk['freesize'];
                           $toupdate['filesystems_id'] = $disk['filesystems_id'];
                           $d->update($toupdate, $install_history);
                           $disk['id'] = $id;
                        }

https://github.com/pluginsGLPI/ocsinventoryng/blob/9fb58e0972fd9da839fd733fd844454c6169b485/inc/disk.class.php#L170