pluginsGLPI / ocsinventoryng

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

Problems on GLPI when updating computer values #325

Open Damien-Pla opened 2 years ago

Damien-Pla commented 2 years ago

Hello,

Technical informations : Glpi Version : 10.0.1 OCS inventory Plugin version : 2.0.1

Each time we try to update computers informations , we have the following error message :

Notice: Trying to access array offset on value of type null in /srv/web/data/glpi/glpi_sources/plugins/ocsinventoryng/inc/ocsserver.class.php on line 1904

Notice: Trying to access array offset on value of type null in /srv/web/data/glpi/glpi_sources/plugins/ocsinventoryng/inc/ocsserver.class.php on line 1906

Notice: Trying to access array offset on value of type null in /srv/web/data/glpi/glpi_sources/plugins/ocsinventoryng/inc/ocsserver.class.php on line 1906

Notice: Trying to access array offset on value of type null in /srv/web/data/glpi/glpi_sources/plugins/ocsinventoryng/inc/ocsserver.class.php on line 1907

Notice: Trying to access array offset on value of type null in /srv/web/data/glpi/glpi_sources/plugins/ocsinventoryng/inc/ocsserver.class.php on line 1907

Warning: mysqli::real_connect(): (HY000/2002): No such file or directory in /srv/web/data/glpi/glpi_sources/plugins/ocsinventoryng/inc/dbocs.class.php on line 96

Warning: mysqli::real_escape_string(): invalid object or resource mysqli in /srv/web/data/glpi/glpi_sources/src/DBmysql.php on line 333

Warning: mysqli::query(): invalid object or resource mysqli in /srv/web/data/glpi/glpi_sources/src/DBmysql.php on line 363

Warning: DBmysql::fetchQueryWarnings(): Property access is not allowed yet in /srv/web/data/glpi/glpi_sources/src/DBmysql.php on line 1897

Notice: Trying to get property 'num_rows' of non-object in /srv/web/data/glpi/glpi_sources/plugins/ocsinventoryng/inc/ocsdbclient.class.php on line 1105

Notice: Trying to access array offset on value of type bool in /srv/web/data/glpi/glpi_sources/plugins/ocsinventoryng/inc/ocsdbclient.class.php on line 79

Warning: mysqli::query(): invalid object or resource mysqli in /srv/web/data/glpi/glpi_sources/src/DBmysql.php on line 363

Warning: DBmysql::fetchQueryWarnings(): Property access is not allowed yet in /srv/web/data/glpi/glpi_sources/src/DBmysql.php on line 1897

The information is still modified in GLPI but we need to click on "previous" to access back to GLPI. We updated from GLPI 9.4 to GLPI 10.0.1 with the OCS inventory plugin to 2.0 then 2.0.1. I didn't think this error happened in the 2.0 but i haven't tested this part extensively so i can't be formal it was working in the 2.0

Please feel free to ask any information i didn't provide, i'll do my best to answer and to help.

Regards, Damien

tsmr commented 2 years ago

What do you have into glpi_plugin_ocsinventoryng_ocsservers table ? only one server ?

Damien-Pla commented 2 years ago

Hello tsmr,

Yes there is only one value inside the table.

id, name, ocs_db_user, ocs_db_passwd, ocs_db_host, ocs_db_name, ocs_db_utf8, checksum, import_periph, import_monitor, import_software, import_printer, import_general_name, import_general_os, import_general_serial, import_general_model, import_general_manufacturer, import_general_type, import_general_domain, import_general_contact, import_general_comment, import_device_processor, import_device_memory, import_device_hdd, import_device_iface, import_device_gfxcard, import_device_sound, import_device_drive, import_device_port, import_device_modem, import_device_bios, import_device_motherboard, import_registry, import_antivirus, import_officepack, import_winupdatestate, import_os_serial, import_ip, import_disk, import_monitor_comment, tag_limit, tag_exclude, use_soft_dict, cron_sync_number, deconnection_behavior, ocs_url, date_mod, comment, is_active, use_massimport, use_locks, deleted_behavior, import_vms, import_general_uuid, import_device_controller, import_device_slot, ocs_version, conn_type, use_cleancron, action_cleancron, use_restorationcron, delay_restorationcron, importsnmp_name, importsnmp_serial, importsnmp_comment, importsnmp_contact, importsnmp_location, importsnmp_domain, importsnmp_manufacturer, importsnmp_createport, importsnmp_last_pages_counter, importsnmp_firmware, importsnmp_power, importsnmp_fan, importsnmp_printermemory, importsnmp_computernetworkcards, importsnmp_computermemory, importsnmp_computerprocessors, importsnmp_computersoftwares, importsnmp_computervm, import_uptime, linksnmp_name, linksnmp_serial, linksnmp_comment, linksnmp_contact, linksnmp_location, linksnmp_domain, linksnmp_manufacturer, linksnmp_createport, linksnmp_last_pages_counter, linksnmp_firmware, linksnmp_power, linksnmp_fan, linksnmp_printermemory, linksnmp_computernetworkcards, linksnmp_computermemory, linksnmp_computerprocessors, linksnmp_computersoftwares, linksnmp_computervm, dohistory, history_hardware, history_bios, history_drives, history_network, history_devices, history_monitor, history_printer, history_peripheral, history_software, history_vm, history_admininfos, use_checkruleimportentity, import_teamviewer, import_proxysetting, import_winusers, import_osinstall, import_networkshare, import_user_location, import_user_group, import_runningprocess, import_service, importsnmp_computerdisks, linksnmp_computerdisks, history_plugins, history_os, import_user_group_default, import_customapp, cleancron_nb_days, import_bitlocker, link_with_user '3', 'OCS-Workstations', 'ocs', 'HASHCONTENT', 'mariadb-glpi', 'OCSINV', '1', '514903', '0', '3', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '0', '0', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', NULL, NULL, '1', '100', 'delete', 'http://ocsworkstations/ocsreports/', '2022-06-21 16:25:49', '', '1', '1', '1', '1', '1', '1', '0', '0', '7057', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0', '1', '1', '0', '0', '0', '0', '0', '0', '1', '0', '90', '0', '1'

Sorry for the ugly block.

Damien-Pla commented 2 years ago

Rollbacked to 2.0.0 and the problem is not happening anymore. Can do tests on our integration environment

MrYsson commented 1 year ago

Hello,

We have a similar issue when importing computers using the version 2.0.2. The error logs are identical. So I looked in the code and it seems that the lines 1344 and 1346 of hook.php are responsible. I removed the functions isset in those lines, giving :

$ocsservers_id = $params['values']['input']['ocsservers_id'] ?? 0;

and

$ocsservers_id = $params['values']['params']['plugin_ocsinventoryng_ocsservers_id'] ?? 0;

respectively and it worked for the few tests we runned.

Explications: With the isset functions, the variable $ocsservers_id was set to true (or false if there was an error) and then it searched the server where id = true, returning nothing. Since it returned null, it caused the 5 firsts rows of the log.

Side effects of the solution: This solution shoudn't impact the error handling, since the isset is performed by the ?? (null coalescing operator) and it returns 0 if there is a problem (I haven't checked the rest of the error handling).

Commit responsible: It appeared in the commit "Fix adding thread in DB" (ef33920), made on 2022-06-13, and it's still the same code in the latest commit (ff8de0f), so it impacts v2.0.1 and v2.0.2.

Actions to do: We didn't run many tests to check this solution, so any review is welcome. If it's okay, I'll let the maintainers of this plugin make the commit to include this patch.