glpi-project / glpi-inventory-plugin

GLPI Inventory plugin
GNU Affero General Public License v3.0
46 stars 27 forks source link

PHP Warning (2): Trying to access array offset on null in statediscovery.class.php at line 168 #491

Closed ipoweb closed 6 months ago

ipoweb commented 6 months ago

Describe the bug

When i try to acces to *i/plugins/glpiinventory/front/statediscovery.php with iis, i get an error with glpi inventory, i get an 500 error

[2024-03-11 15:21:30] glpiphplog.WARNING:   *** PHP Warning (2): Trying to access array offset on null in C:\****\plugins\glpiinventory\inc\statediscovery.class.php at line 168
  Backtrace :
  plugins\glpiinventory\front\statediscovery.php:49  PluginGlpiinventoryStateDiscovery->display()
  public\index.php:82                                require()

GLPI Version : 10.0.12 GLPI Agent : 1.3.5

To reproduce

  1. PHP 8.3
  2. IIS 10
  3. URL REWRITING
  4. MariaDB 10.11

Expected behavior

acces to state discovery without error

Operating system

Windows

GLPI Agent version

1.3

GLPI version

10.0.12

GLPIInventory plugin

1.3.5

Additional context

No response

stonebuzz commented 6 months ago

Hi @ipoweb

you must have an SQL error when displaying the page (you need to look in the sql-error.logs) can you confirm this?

ipoweb commented 6 months ago

this file is inside GLPI Folder or it's a configuration with MariaDB ? if it's mariaDB, i added log file error, but i don't have any Mysql error when i try i click on button : network -> State of Discovery Maybe i need to declare Range IP ?

stonebuzz commented 6 months ago

Look here

/path/to/glpi/files/_log/sql-error.log

ipoweb commented 6 months ago

very strange, i dont have any file named sql-error.log

ipoweb commented 6 months ago

i check tables glpi_plugin_glpiinventory_taskjobstates & glpi_plugin_glpiinventory_taskjobs, i have no entries in theses tables

// Total Number of events $iterator = $DB->request([ 'COUNT' => 'cpt', 'FROM' => 'glpi_plugin_glpiinventory_taskjobstates', 'LEFT JOIN' => [ 'glpi_plugin_glpiinventory_taskjobs' => [ 'FKEY' => [ 'glpi_plugin_glpiinventory_taskjobstates' => 'plugin_glpiinventory_taskjobs_id', 'glpi_plugin_glpiinventory_taskjobs' => 'id' ] ] ], 'WHERE' => [ 'method' => 'networkdiscovery' ], 'GROUP' => 'uniqid', 'ORDER' => 'uniqid DESC' ]); $result = $iterator->next(); $number = $result['cpt'];

stonebuzz commented 6 months ago

Retry with sql-errors.log file name under glpi/files/_log/ folder

meulie commented 6 months ago

Same error on GLPI Version : 10.0.13 No sql-errors.log in glpi/files/_log/ folder

ipoweb commented 6 months ago

no sql-errors.log exist, i created it but not error

trasher commented 6 months ago

We need a way to reproduce from a fresh install; since we have no idea how to get this error without context.