fusioninventory / fusioninventory-for-glpi

FusionInventory plugin for GLPI
http://www.FusionInventory.org/
GNU Affero General Public License v3.0
361 stars 148 forks source link

"Invalid argument supplied for foreach()" into FusionInventory groups when "Additional fields" plugin is enabled #3102

Open eduardomozart opened 3 years ago

eduardomozart commented 3 years ago

GLPI version: 9.5.3 FusionInventory for GLPI version: FusionInventory 9.5.0+1.0

The following error is thrown when clicking into a FusionInventory group when "Additional fields" plugin is enabled (requires "Debug mode" enabled).

screenshot

The following error is thown into <GLPI_ROOT>\files\_log\php-errors.log:

[2021-03-04 19:50:54] glpiphplog.WARNING:   *** PHP Warning (2): Invalid argument supplied for foreach() in /var/www/clients/client0/web1/web/plugins/fusion$
  Backtrace :
  inc/commondbtm.class.php:3644                      PluginFusioninventoryComputer->rawSearchOptions()
  inc/search.class.php:6910                          CommonDBTM->searchOptions()
  inc/search.class.php:6717                          Search::getOptions()
  inc/search.class.php:2485                          Search::getCleanedOptions()
  inc/search.class.php:2314                          Search::displayCriteria()
  ...s/fusioninventory/inc/deploygroup.class.php:544 Search::showGenericSearch()
  ...ntory/inc/deploygroup_dynamicdata.class.php:208 PluginFusioninventoryDeployGroup::showCriteria()
  ...ntory/inc/deploygroup_dynamicdata.class.php:158 PluginFusioninventoryDeployGroup_Dynamicdata::showCriteriaAndSearch()
  inc/commonglpi.class.php:637                       PluginFusioninventoryDeployGroup_Dynamicdata::displayTabContentForItem()
  ajax/common.tabs.php:101                           CommonGLPI::displayStandardTab()

2021-03-04 19:50:54 [168@ispconfig.sulcromo.com.br]
includeLocales(softversioninstallations_report_title, reports) => not found
2021-03-04 19:50:54 [168@ispconfig.sulcromo.com.br]
includeLocales(statusertask_report_title, reports) => not found
[2021-03-04 19:50:54] glpiphplog.WARNING:   *** PHP Warning (2): Invalid argument supplied for foreach() in /var/www/clients/client0/web1/web/plugins/fusion$
  Backtrace :
  inc/commondbtm.class.php:3644                      PluginFusioninventoryComputer->rawSearchOptions()
  inc/search.class.php:6910                          CommonDBTM->searchOptions()
  inc/search.class.php:6717                          Search::getOptions()
  inc/search.class.php:502                           Search::getCleanedOptions()
  ...ntory/inc/deploygroup_dynamicdata.class.php:131 Search::prepareDatasForSearch()
  ...entory/inc/deploygroup_dynamicdata.class.php:93 PluginFusioninventoryDeployGroup_Dynamicdata->getMatchingItemsCount()
  inc/commonglpi.class.php:339                       PluginFusioninventoryDeployGroup_Dynamicdata->getTabNameForItem()
  inc/commonglpi.class.php:302                       CommonGLPI->addStandardTab()
  ajax/updatecurrenttab.php:46                       CommonGLPI->defineAllTabs()

The following error is thrown into Apache error.log:

[Thu Mar 04 19:50:54.329756 2021] [proxy_fcgi:error] [pid 3659] [client 192.168.2.36:49192] AH01071: Got error 'PHP message: PHP Warning:  Invalid argument supplied for foreach() in /var/www/clients/client0/web1/web/plugins/fusioninventory/inc/computer.class.php on line 77\n', referer: https://glpi.sulcromo.com.br/plugins/fusioninventory/front/deploygroup.form.php?id=1

No error is thrown into any other logs into <GLPI_ROOT>/files/_log folder and into Apache access.log.

I decided to dig into the line 77 of <GLPI_ROOT>/plugins/fusioninventory/inc/computer.class.php file and it's simply detects if fields plugin is enabled and runs a custom query, but it apparently fails. Maybe there was some code change into fields plugin and a new adaptation for FusionInventory for GLPI is necessary? Apparently this custom query is to show custom fields into "Criteria" list for FusionInventory groups.

GLPI information:

[code]

GLPI 9.5.4 ( => /var/www/clients/client0/web1/web)
Installation mode: TARBALL

Server

Operating system: Linux ispconfig.example.com 4.18.0-240.10.1.el8_3.x86_64 #1 SMP Mon Jan 18 17:05:51 UTC 2021 x86_64
PHP 7.2.34 fpm-fcgi (Core, PDO, PDO_ODBC, Phar, Reflection, SPL, SimpleXML, Zend OPcache, apcu, bcmath, bz2, calendar, cgi-fcgi,
    ctype, curl, date, dom, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, imap, intl, json, ldap, libxml, mbstring, mcrypt,
    mysql, mysqli, mysqlnd, odbc, openssl, pcre, pdo_mysql, pdo_sqlite, posix, session, shmop, snmp, soap, sockets, sodium, sqlite3,
    standard, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib)
Setup: max_execution_time="600" memory_limit="128M" post_max_size="150 M" safe_mode="" session.save_handler="files"
    upload_max_filesize="150M" 
Software: Apache ()
    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36
Server Software: MariaDB Server
    Server Version: 10.3.27-MariaDB
    Server SQL Mode: 
    Parameters: c0glpiuser@localhost/c0glpi
    Host info: Localhost via UNIX socket

PHP version is at least 7.2.0 - Perfect!PHP version is at least 7.2.0 - Perfect!
Sessions support is available - Perfect!Sessions support is available - Perfect!
Allocated memory > 64 Mio - Perfect!Allocated memory > 64 Mio - Perfect!
mysqli extension is installedmysqli extension is installed
ctype extension is installedctype extension is installed
fileinfo extension is installedfileinfo extension is installed
json extension is installedjson extension is installed
mbstring extension is installedmbstring extension is installed
iconv extension is installediconv extension is installed
zlib extension is installedzlib extension is installed
curl extension is installedcurl extension is installed
gd extension is installedgd extension is installed
simplexml extension is installedsimplexml extension is installed
intl extension is installedintl extension is installed
ldap extension is installedldap extension is installed
apcu extension is installedapcu extension is installed
Zend OPcache extension is installedZend OPcache extension is installed
xmlrpc extension is installedxmlrpc extension is installed
CAS extension is installedCAS extension is installed
exif extension is installedexif extension is installed
zip extension is installedzip extension is installed
bz2 extension is installedbz2 extension is installed
sodium extension is installedsodium extension is installed
Database version seems correct (10.3.27) - Perfect!Database version seems correct (10.3.27) - Perfect!
Timezones seems loaded in databaseTimezones seems loaded in database
The log file has been created successfully.The log file has been created successfully.
Write access to /var/www/clients/client0/web1/web/files/_cache has been validated.Write access to /var/www/clients/client0/web1/web/files/_cache has been validated.
Write access to /var/www/clients/client0/web1/web/config has been validated.Write access to /var/www/clients/client0/web1/web/config has been validated.
Write access to /var/www/clients/client0/web1/web/files/_cron has been validated.Write access to /var/www/clients/client0/web1/web/files/_cron has been validated.
Write access to /var/www/clients/client0/web1/web/files has been validated.Write access to /var/www/clients/client0/web1/web/files has been validated.
Write access to /var/www/clients/client0/web1/web/files/_dumps has been validated.Write access to /var/www/clients/client0/web1/web/files/_dumps has been validated.
Write access to /var/www/clients/client0/web1/web/files/_graphs has been validated.Write access to /var/www/clients/client0/web1/web/files/_graphs has been validated.
Write access to /var/www/clients/client0/web1/web/files/_lock has been validated.Write access to /var/www/clients/client0/web1/web/files/_lock has been validated.
Write access to /var/www/clients/client0/web1/web/files/_pictures has been validated.Write access to /var/www/clients/client0/web1/web/files/_pictures has been validated.
Write access to /var/www/clients/client0/web1/web/files/_plugins has been validated.Write access to /var/www/clients/client0/web1/web/files/_plugins has been validated.
Write access to /var/www/clients/client0/web1/web/files/_rss has been validated.Write access to /var/www/clients/client0/web1/web/files/_rss has been validated.
Write access to /var/www/clients/client0/web1/web/files/_sessions has been validated.Write access to /var/www/clients/client0/web1/web/files/_sessions has been validated.
Write access to /var/www/clients/client0/web1/web/files/_tmp has been validated.Write access to /var/www/clients/client0/web1/web/files/_tmp has been validated.
Write access to /var/www/clients/client0/web1/web/files/_uploads has been validated.Write access to /var/www/clients/client0/web1/web/files/_uploads has been validated.
Write access to /var/www/clients/client0/web1/web/marketplace has been validated.Write access to /var/www/clients/client0/web1/web/marketplace has been validated.
Web access to files directory is protectedWeb access to files directory is protected
For security reasons, SELinux mode should be Enforcing.For security reasons, SELinux mode should be Enforcing.

GLPI constants

GLPI_ROOT: /var/www/clients/client0/web1/web
GLPI_CONFIG_DIR: /var/www/clients/client0/web1/web/config
GLPI_VAR_DIR: /var/www/clients/client0/web1/web/files
GLPI_MARKETPLACE_DIR: /var/www/clients/client0/web1/web/marketplace
GLPI_USE_CSRF_CHECK: 1
GLPI_CSRF_EXPIRES: 7200
GLPI_CSRF_MAX_TOKENS: 100
GLPI_USE_IDOR_CHECK: 1
GLPI_IDOR_EXPIRES: 7200
GLPI_ALLOW_IFRAME_IN_RICH_TEXT: 
GLPI_TELEMETRY_URI: https://telemetry.glpi-project.org
GLPI_INSTALL_MODE: TARBALL
GLPI_NETWORK_MAIL: glpi@teclib.com
GLPI_NETWORK_SERVICES: https://services.glpi-network.com
GLPI_MARKETPLACE_PRERELEASES: 
GLPI_USER_AGENT_EXTRA_COMMENTS: 
GLPI_AJAX_DASHBOARD: 1
GLPI_CALDAV_IMPORT_STATE: 0
GLPI_DEMO_MODE: 0
GLPI_FORCE_EMPTY_SQL_MODE: 1
GLPI_DOC_DIR: /var/www/clients/client0/web1/web/files
GLPI_CACHE_DIR: /var/www/clients/client0/web1/web/files/_cache
GLPI_CRON_DIR: /var/www/clients/client0/web1/web/files/_cron
GLPI_DUMP_DIR: /var/www/clients/client0/web1/web/files/_dumps
GLPI_GRAPH_DIR: /var/www/clients/client0/web1/web/files/_graphs
GLPI_LOCAL_I18N_DIR: /var/www/clients/client0/web1/web/files/_locales
GLPI_LOCK_DIR: /var/www/clients/client0/web1/web/files/_lock
GLPI_LOG_DIR: /var/www/clients/client0/web1/web/files/_log
GLPI_PICTURE_DIR: /var/www/clients/client0/web1/web/files/_pictures
GLPI_PLUGIN_DOC_DIR: /var/www/clients/client0/web1/web/files/_plugins
GLPI_RSS_DIR: /var/www/clients/client0/web1/web/files/_rss
GLPI_SESSION_DIR: /var/www/clients/client0/web1/web/files/_sessions
GLPI_TMP_DIR: /var/www/clients/client0/web1/web/files/_tmp
GLPI_UPLOAD_DIR: /var/www/clients/client0/web1/web/files/_uploads
GLPI_NETWORK_REGISTRATION_API_URL: https://services.glpi-network.com/api/registration/
GLPI_MARKETPLACE_PLUGINS_API_URI: https://services.glpi-network.com/api/glpi-plugins/
GLPI_I18N_DIR: /var/www/clients/client0/web1/web/locales
GLPI_VERSION: 9.5.4
GLPI_SCHEMA_VERSION: 9.5.4
GLPI_MIN_PHP: 7.2.0
GLPI_YEAR: 2021

Libraries

htmlawed/htmlawed version 1.2.5 in (/var/www/clients/client0/web1/web/vendor/htmlawed/htmlawed)
phpmailer/phpmailer version 6.1.6 in (/var/www/clients/client0/web1/web/vendor/phpmailer/phpmailer/src)
simplepie/simplepie version 1.5.6 in (/var/www/clients/client0/web1/web/vendor/simplepie/simplepie/library)
tecnickcom/tcpdf version 6.3.5 in (/var/www/clients/client0/web1/web/vendor/tecnickcom/tcpdf)
michelf/php-markdown in (/var/www/clients/client0/web1/web/vendor/michelf/php-markdown/Michelf)
true/punycode in (/var/www/clients/client0/web1/web/vendor/true/punycode/src)
iamcal/lib_autolink in (/var/www/clients/client0/web1/web/vendor/iamcal/lib_autolink)
sabre/dav in (/var/www/clients/client0/web1/web/vendor/sabre/dav/lib/DAV)
sabre/http in (/var/www/clients/client0/web1/web/vendor/sabre/http/lib)
sabre/uri in (/var/www/clients/client0/web1/web/vendor/sabre/uri/lib)
sabre/vobject in (/var/www/clients/client0/web1/web/vendor/sabre/vobject/lib)
laminas/laminas-cache in (/var/www/clients/client0/web1/web/vendor/laminas/laminas-cache/src)
laminas/laminas-i18n in (/var/www/clients/client0/web1/web/vendor/laminas/laminas-i18n/src)
laminas/laminas-serializer in (/var/www/clients/client0/web1/web/vendor/laminas/laminas-serializer/src)
monolog/monolog in (/var/www/clients/client0/web1/web/vendor/monolog/monolog/src/Monolog)
sebastian/diff in (/var/www/clients/client0/web1/web/vendor/sebastian/diff/src)
elvanto/litemoji in (/var/www/clients/client0/web1/web/vendor/elvanto/litemoji/src)
symfony/console in (/var/www/clients/client0/web1/web/vendor/symfony/console)
scssphp/scssphp in (/var/www/clients/client0/web1/web/vendor/scssphp/scssphp/src)
laminas/laminas-mail in (/var/www/clients/client0/web1/web/vendor/laminas/laminas-mail/src/Protocol)
laminas/laminas-mime in (/var/www/clients/client0/web1/web/vendor/laminas/laminas-mime/src)
rlanvin/php-rrule in (/var/www/clients/client0/web1/web/vendor/rlanvin/php-rrule/src)
blueimp/jquery-file-upload in (/var/www/clients/client0/web1/web/vendor/blueimp/jquery-file-upload/server/php)
ramsey/uuid in (/var/www/clients/client0/web1/web/vendor/ramsey/uuid/src)
psr/log in (/var/www/clients/client0/web1/web/vendor/psr/log/Psr/Log)
psr/simple-cache in (/var/www/clients/client0/web1/web/vendor/psr/simple-cache/src)
mexitek/phpcolors in (/var/www/clients/client0/web1/web/vendor/mexitek/phpcolors/src/Mexitek/PHPColors)
guzzlehttp/guzzle in (/var/www/clients/client0/web1/web/vendor/guzzlehttp/guzzle/src)
guzzlehttp/psr7 in (/var/www/clients/client0/web1/web/vendor/guzzlehttp/psr7/src)
wapmorgan/unified-archive in (/var/www/clients/client0/web1/web/vendor/wapmorgan/unified-archive/src)
paragonie/sodium_compat in (/var/www/clients/client0/web1/web/vendor/paragonie/sodium_compat/src)
phpCas version 1.3.8 in (/usr/share/pear)

LDAP directories

Server: 'ldaps://example.com', Port: '389', BaseDN: 'OU=example,DC=example,DC=com,DC=br', Connection filter:
        '(&(objectClass=user)(objectCategory=person)(!(userAccountControl:1.2.840.113556.1.4.803:=2))(!(memberOf=CN=Contas de Serviço -
        Negar Logon Interativo,OU=Serviços,OU=TI,OU=São
        Leopoldo,OU=example,DC=example,DC=com,DC=br))(!(sAMAccountName=fabrica))(!(sAMAccountName=cq))(!(sAMAccountName=manutencao)))',
        RootDN: 'glpiaduser@example.com', Use TLS: none

SQL replicas

Not active

Notifications

Way of sending emails: SMTP+SSL (glpi@example.com@smtp.kinghost.net)

Mails receivers

Name: 'glpi@example.com' Active: Yes
    Server: '{smtp.kinghost.net:995/pop/ssl/validate-cert}' Login: 'glpi@example.com' Password: Yes

Plugins list

    fields               Name: Campos adicionais              Version: 1.12.2     State: Enabled
    behaviors            Name: Comportamentos                 Version: 2.4.1      State: Enabled
    accounts             Name: Contas                         Version: 2.6.0      State: Enabled
    archimap             Name: Diagrams                       Version: 2.2.1      State: Enabled
    fusioninventory      Name: FusionInventory                Version: 9.5+2.0  State: Enabled
    genericobject        Name: Gerenciamento de objetos       Version: 2.10.0     State: Installed / not activated
    manufacturersimports Name: Importação de fornecedores     Version: 2.3.1      State: Enabled
    pdf                  Name: Imprimir em PDF                Version: 1.7.0      State: Enabled
    mreporting           Name: Mais Relatórios                Version: 1.7.1      State: Enabled
    printercounters      Name: Printer counters               Version: 1.7.0      State: Enabled
    reports              Name: Relatórios                     Version: 1.14.0     State: Enabled
    taskdrop             Name: TaskDrop                       Version: 1.2.0      State: Enabled

[/code]
ddurieux commented 3 years ago

Seems you haven't regenerate container files after created additional fileds

eduardomozart commented 3 years ago

I did "Regenerate container files" through "Additional fields" plug-in page and upgraded to GLPI 9.5.4 but the issue still persists. I even did a clean install of "FusionInventory for GLPI 9.5.0+2.0" (released yesterday) and "Additional fields" plug-in. There's no custom field anymore but this error is still being triggered. I did update the "Additional fields" plug-in from version 1.11.0 to version 1.12.2. After upgrading FusionInventory for GLPI plug-in to 9.5.0+2.0, instead of line 76, the error is triggered by line 77. I did update the original description of this bug report to reflect theses changes.