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.18k stars 1.28k forks source link

Incorrect integer value: 'Dell, Inc.' for column 'manufacturers_id' at row 1 (ruledictionnarymanufacturer) #12811

Closed fralla2 closed 2 years ago

fralla2 commented 2 years ago

Code of Conduct

Is there an existing issue for this?

Version

10.0.3

Bug description

When having dictionary rule active for manufacturer (might also affect other dictionary rules too), the name is returned instead of the id when trying to import the device in GLPI using native inventory. This throws errors like this one and prevent import of the new device

Error: Incorrect integer value: 'Dell, Inc.' for column 'manufacturers_id' at row 1

Relevant log output

*** MySQL query error:
  SQL: INSERT INTO `glpi_computers` (`autoupdatesystems_id`, `last_inventory_update`, `name`, `uuid`, `users_id`, `computertypes_id`, `contact`, `manufacturers_id`, `computermodels_id`, `serial`, `is_dynamic`, `entities_id`, `states_id`, `otherserial`, `date_creation`, `date_mod`) VALUES ('1', '2022-09-29 09:34:32', 'STI2021-215-003', '4C4C4544-0054-4D10-804C-C3C04F364433', '0', '29', 'm4058@CSCV', 'Dell, Inc.', '370', 'CTML6D3', '1', '4', '0', 'CSSCV0000019357', '2022-09-29 09:34:32', '2022-09-29 09:34:32')
  Error: Incorrect integer value: 'Dell, Inc.' for column 'manufacturers_id' at row 1
  Backtrace :
  src/DBmysql.php:1312
  src/CommonDBTM.php:716                             DBmysql->insert()
  src/CommonDBTM.php:1321                            CommonDBTM->addToDB()
  src/Inventory/Asset/MainAsset.php:660              CommonDBTM->add()
  src/RuleImportAsset.php:965                        Glpi\Inventory\Asset\MainAsset->rulepassed()
  src/Rule.php:1510                                  RuleImportAsset->executeActions()
  src/RuleCollection.php:1591                        Rule->process()
  src/Inventory/Asset/MainAsset.php:554              RuleCollection->processAllRules()
  src/Inventory/Inventory.php:701                    Glpi\Inventory\Asset\MainAsset->handle()
  src/Inventory/Inventory.php:336                    Glpi\Inventory\Inventory->handleItem()
  src/Inventory/Request.php:360                      Glpi\Inventory\Inventory->doInventory()
  src/Inventory/Request.php:90                       Glpi\Inventory\Request->inventory()
  src/Agent/Communication/AbstractRequest.php:305    Glpi\Inventory\Request->handleAction()
  src/Agent/Communication/AbstractRequest.php:242    Glpi\Agent\Communication\AbstractRequest->handleXMLRequest()
  front/inventory.php:86                             Glpi\Agent\Communication\AbstractRequest->handleRequest()
  {"user":"inventory@deimos01"}

Page URL

No response

Steps To reproduce

  1. Create a dictionary rule for the computer manufacturer like this one : image

  2. Try to import the computer to native glpi inventory (this throw a lot of error in the log files related to incorrect integer value

  3. Disable the dictionary rule

  4. Try to import again (works fine)

Note : This was working correctly in GLPI 9.5.7

Your GLPI setup information

Informations sur le système, l'installation et la configuration
GLPI 10.0.3 (/glpi-10.0.3 => /var/www/html/glpi-10.0.3)
Installation mode: TARBALL
Current language:fr_FR

Server
 
Operating system: Linux deimos01 4.18.0-408.el8.x86_64 #1 SMP Mon Jul 18 17:42:52 UTC 2022 x86_64
PHP 8.1.11 fpm-fcgi (Core, PDO, 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, mysqli,
    mysqlnd, openssl, pcre, pdo_mysql, pdo_sqlite, posix, session, shmop, soap, sockets, sodium, sqlite3, standard, sysvmsg,
    sysvsem, sysvshm, tokenizer, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib)
Setup: max_execution_time="600" memory_limit="256M" post_max_size="100M" safe_mode="" session.save_handler="files"
    upload_max_filesize="100M" 
Software: Apache/2.4.37 (centos) OpenSSL/1.1.1k ()
    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
Server Software: Source distribution
    Server Version: 8.0.26
    Server SQL Mode: STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
    Parameters: REDACTED
    Host info: REDACTED via TCP/IP

PHP version (8.1.11) is supported.
Sessions configuration is OK.
Allocated memory is sufficient.
mysqli extension is installed.
Following extensions are installed: dom, fileinfo, json, simplexml.
curl extension is installed.
gd extension is installed.
intl extension is installed.
libxml extension is installed.
zlib extension is installed.
The constant SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES is present.
Database engine version (8.0.26) is supported.
The log file has been created successfully.
Write access to /var/www/glpiData/files/_cache has been validated.
Write access to /var/www/glpiData/config/ has been validated.
Write access to /var/www/glpiData/files/_cron has been validated.
Write access to /var/www/glpiData/files has been validated.
Write access to /var/www/glpiData/files/_dumps has been validated.
Write access to /var/www/glpiData/files/_graphs has been validated.
Write access to /var/www/glpiData/files/_lock has been validated.
Write access to /var/www/glpiData/files/_pictures has been validated.
Write access to /var/www/glpiData/files/_plugins has been validated.
Write access to /var/www/glpiData/files/_rss has been validated.
Write access to /var/www/glpiData/files/_sessions has been validated.
Write access to /var/www/glpiData/files/_tmp has been validated.
Write access to /var/www/glpiData/files/_uploads has been validated.
For security reasons, SELinux mode should be Enforcing.
PHP directive "session.cookie_secure" should be set to "on" when GLPI can be accessed on HTTPS protocol.
PHP directive "session.cookie_httponly" should be set to "on" to prevent client-side script to access cookie values.
exif extension is installed.
ldap extension is installed.
openssl extension is installed.
zip extension is installed.
bz2 extension is installed.
Zend OPcache extension is installed.
Following extensions are installed: ctype, iconv, mbstring, sodium.
Write access to /var/www/html/glpi-10.0.3/marketplace has been validated.
Timezones seems loaded in database.

GLPI constants
 
GLPI_ROOT: /var/www/html/glpi-10.0.3
GLPI_CONFIG_DIR: /var/www/glpiData/config/
GLPI_VAR_DIR: /var/www/glpiData/files
GLPI_LOG_DIR: /var/log/glpi
GLPI_MARKETPLACE_DIR: /var/www/html/glpi-10.0.3/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_SERVERSIDE_URL_ALLOWLIST: Array
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_ALLOW_OVERRIDE: 1
GLPI_MARKETPLACE_MANUAL_DOWNLOADS: 1
GLPI_USER_AGENT_EXTRA_COMMENTS: 
GLPI_DISABLE_ONLY_FULL_GROUP_BY_SQL_MODE: 1
GLPI_AJAX_DASHBOARD: 1
GLPI_CALDAV_IMPORT_STATE: 0
GLPI_DEMO_MODE: 0
GLPI_CENTRAL_WARNINGS: 1
GLPI_DOC_DIR: /var/www/glpiData/files
GLPI_CACHE_DIR: /var/www/glpiData/files/_cache
GLPI_CRON_DIR: /var/www/glpiData/files/_cron
GLPI_DUMP_DIR: /var/www/glpiData/files/_dumps
GLPI_GRAPH_DIR: /var/www/glpiData/files/_graphs
GLPI_LOCAL_I18N_DIR: /var/www/glpiData/files/_locales
GLPI_LOCK_DIR: /var/www/glpiData/files/_lock
GLPI_PICTURE_DIR: /var/www/glpiData/files/_pictures
GLPI_PLUGIN_DOC_DIR: /var/www/glpiData/files/_plugins
GLPI_RSS_DIR: /var/www/glpiData/files/_rss
GLPI_SESSION_DIR: /var/www/glpiData/files/_sessions
GLPI_TMP_DIR: /var/www/glpiData/files/_tmp
GLPI_UPLOAD_DIR: /var/www/glpiData/files/_uploads
GLPI_INVENTORY_DIR: /var/www/glpiData/files/_inventories
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/html/glpi-10.0.3/locales
GLPI_VERSION: 10.0.3
GLPI_SCHEMA_VERSION: 10.0.3@a130db99c7d9b131c2e2ea59fe0d6260fe93d831
GLPI_MARKETPLACE_PRERELEASES: 
GLPI_MIN_PHP: 7.4.0
GLPI_MAX_PHP: 8.3.0
GLPI_YEAR: 2022

Libraries
 
htmlawed/htmlawed version 1.2.9 in (/var/www/html/glpi-10.0.3/vendor/htmlawed/htmlawed)
phpmailer/phpmailer version 6.6.0 in (/var/www/html/glpi-10.0.3/vendor/phpmailer/phpmailer/src)
simplepie/simplepie version 1.5.8 in (/var/www/html/glpi-10.0.3/vendor/simplepie/simplepie/library)
tecnickcom/tcpdf version 6.5.0 in (/var/www/html/glpi-10.0.3/vendor/tecnickcom/tcpdf)
michelf/php-markdown in (/var/www/html/glpi-10.0.3/vendor/michelf/php-markdown/Michelf)
true/punycode in (/var/www/html/glpi-10.0.3/vendor/true/punycode/src)
iamcal/lib_autolink in (/var/www/html/glpi-10.0.3/vendor/iamcal/lib_autolink)
sabre/dav in (/var/www/html/glpi-10.0.3/vendor/sabre/dav/lib/DAV)
sabre/http in (/var/www/html/glpi-10.0.3/vendor/sabre/http/lib)
sabre/uri in (/var/www/html/glpi-10.0.3/vendor/sabre/uri/lib)
sabre/vobject in (/var/www/html/glpi-10.0.3/vendor/sabre/vobject/lib)
laminas/laminas-i18n in (/var/www/html/glpi-10.0.3/vendor/laminas/laminas-i18n/src)
laminas/laminas-servicemanager in (/var/www/html/glpi-10.0.3/vendor/laminas/laminas-servicemanager/src)
monolog/monolog in (/var/www/html/glpi-10.0.3/vendor/monolog/monolog/src/Monolog)
sebastian/diff in (/var/www/html/glpi-10.0.3/vendor/sebastian/diff/src)
donatj/phpuseragentparser in (/var/www/html/glpi-10.0.3/vendor/donatj/phpuseragentparser/src/UserAgent)
elvanto/litemoji in (/var/www/html/glpi-10.0.3/vendor/elvanto/litemoji/src)
symfony/console in (/var/www/html/glpi-10.0.3/vendor/symfony/console)
scssphp/scssphp in (/var/www/html/glpi-10.0.3/vendor/scssphp/scssphp/src)
laminas/laminas-mail in (/var/www/html/glpi-10.0.3/vendor/laminas/laminas-mail/src/Protocol)
laminas/laminas-mime in (/var/www/html/glpi-10.0.3/vendor/laminas/laminas-mime/src)
rlanvin/php-rrule in (/var/www/html/glpi-10.0.3/vendor/rlanvin/php-rrule/src)
blueimp/jquery-file-upload in (/var/www/html/glpi-10.0.3/vendor/blueimp/jquery-file-upload/server/php)
ramsey/uuid in (/var/www/html/glpi-10.0.3/vendor/ramsey/uuid/src)
psr/log in (/var/www/html/glpi-10.0.3/vendor/psr/log/Psr/Log)
psr/simple-cache in (/var/www/html/glpi-10.0.3/vendor/psr/simple-cache/src)
psr/cache in (/var/www/html/glpi-10.0.3/vendor/psr/cache/src)
league/csv in (/var/www/html/glpi-10.0.3/vendor/league/csv/src)
mexitek/phpcolors in (/var/www/html/glpi-10.0.3/vendor/mexitek/phpcolors/src/Mexitek/PHPColors)
guzzlehttp/guzzle in (/var/www/html/glpi-10.0.3/vendor/guzzlehttp/guzzle/src)
guzzlehttp/psr7 in (/var/www/html/glpi-10.0.3/vendor/guzzlehttp/psr7/src)
glpi-project/inventory_format in (/var/www/html/glpi-10.0.3/vendor/glpi-project/inventory_format/lib/php)
wapmorgan/unified-archive in (/var/www/html/glpi-10.0.3/vendor/wapmorgan/unified-archive/src)
paragonie/sodium_compat in (/var/www/html/glpi-10.0.3/vendor/paragonie/sodium_compat/src)
symfony/cache in (/var/www/html/glpi-10.0.3/vendor/symfony/cache)
html2text/html2text in (/var/www/html/glpi-10.0.3/vendor/html2text/html2text/src)
symfony/css-selector in (/var/www/html/glpi-10.0.3/vendor/symfony/css-selector)
symfony/dom-crawler in (/var/www/html/glpi-10.0.3/vendor/symfony/dom-crawler)
twig/twig in (/var/www/html/glpi-10.0.3/vendor/twig/twig/src)
twig/string-extra in (/var/www/html/glpi-10.0.3/vendor/twig/string-extra)
symfony/polyfill-ctype not found
symfony/polyfill-iconv not found
symfony/polyfill-mbstring not found
symfony/polyfill-php80 not found
symfony/polyfill-php81 not found
symfony/polyfill-php82 in (/var/www/html/glpi-10.0.3/vendor/symfony/polyfill-php82)

REDACTEDSQL replicas
 
Not active

Notifications
 
Way of sending emails: SMTP+TLS (REDACTED)

Plugins list
 
    advancedplanning     Name: advancedplanning               Version: 1.1.0      State: Enabled                                 
        Install Method: Marketplace
    treeview             Name: Arborescence                   Version: 1.10.0     State: Enabled                                 
        Install Method: Marketplace
    fields               Name: Champs supplémentaires         Version: 1.17.3     State: Enabled                                 
        Install Method: Marketplace
    csscvinventorylabels Name: CSSCV Inventory Labels         Version: 1.0.1      State: Enabled                                 
        Install Method: Manual
    datainjection        Name: Data Injection                 Version: 2.12.0     State: Enabled                                 
        Install Method: Marketplace
    formcreator          Name: Form Creator                   Version: 2.13.1     State: Enabled                                 
        Install Method: Marketplace
    geninventorynumber   Name: Génération de numéros d'invent Version: 2.8.2      State: Enabled                                
         Install Method: Marketplace
    genericobject        Name: Gestion d'objets               Version: 2.13.0     State: Enabled                                 
        Install Method: Marketplace
    order                Name: Gestion des commandes          Version: 2.9.0      State: Enabled                                 
        Install Method: Marketplace
    tag                  Name: Gestion des tags               Version: 2.10.0     State: Enabled                                 
        Install Method: Marketplace
    manufacturersimports Name: Imports fabricants             Version: 3.0.2      State: Enabled                                 
        Install Method: Marketplace
    jamfschool           Name: JamfSchool                     Version: 1.0.1      State: Installed / not activated               
        Install Method: Manual
    oauthimap            Name: Oauth IMAP                     Version: 1.4.1      State: Enabled                                 
        Install Method: Marketplace
    taskdrop             Name: TaskDrop                       Version: 2.0.0      State: Enabled                                 
        Install Method: Marketplace

Anything else?

No response

fralla2 commented 2 years ago

@trasher Do you want me to test the fix on my setup or it's still have some work to do on it before? Thanks Francois

trasher commented 2 years ago

I think you can test on your environment. PR is not apporved yet; but I do not think there will be huge changes ;)

fralla2 commented 2 years ago

This looks like it did the trick 👍

Thanks @trasher

fralla2 commented 2 years ago

I see the same problem now that GLPI Inventory is activated but on another table :

[2022-10-03 10:25:03] glpisqllog.ERROR: DBmysql::query() in /var/www/html/glpi-10.0.3/src/DBmysql.php line 370 *** MySQL query error: SQL: INSERT INTO glpi_devicecontrols (designation, manufacturers_id, interfacetypes_id, date_creation, date_mod) VALUES ('H81 Express LPC Controller', 'Intel Corporation', '217', '2022-10-03 10:24:59', '2022-10-03 10:24:59') Error: Incorrect integer value: 'Intel Corporation' for column 'manufacturers_id' at row 1 Backtrace : src/DBmysql.php:1312
src/CommonDBTM.php:716 DBmysql->insert() src/CommonDBTM.php:1321 CommonDBTM->addToDB() src/CommonDevice.php:512 CommonDBTM->add() src/Inventory/Asset/Device.php:121 CommonDevice->import() src/Inventory/Asset/Controller.php:98 Glpi\Inventory\Asset\Device->handle() src/Inventory/Asset/MainAsset.php:847 Glpi\Inventory\Asset\Controller->handle() src/Inventory/Asset/MainAsset.php:754 Glpi\Inventory\Asset\MainAsset->handleAssets() src/RuleImportAsset.php:946 Glpi\Inventory\Asset\MainAsset->rulepassed() src/Rule.php:1510 RuleImportAsset->executeActions() src/RuleCollection.php:1591 Rule->process() src/Inventory/Asset/MainAsset.php:554 RuleCollection->processAllRules() src/Inventory/Inventory.php:701 Glpi\Inventory\Asset\MainAsset->handle() src/Inventory/Inventory.php:336 Glpi\Inventory\Inventory->handleItem() src/Inventory/Request.php:360 Glpi\Inventory\Inventory->doInventory() src/Inventory/Request.php:90 Glpi\Inventory\Request->inventory() src/Agent/Communication/AbstractRequest.php:305 Glpi\Inventory\Request->handleAction() src/Agent/Communication/AbstractRequest.php:242 Glpi\Agent\Communication\AbstractRequest->handleXMLRequest() front/inventory.php:86 Glpi\Agent\Communication\AbstractRequest->handleRequest() {"user":"@host","mem_usage":"0.001\", 7.48Mio)"}

trasher commented 2 years ago

Are you sure the fix from the PR is still activated?

fralla2 commented 2 years ago

Yes the file src/Inventory/Asset/InventoryAsset.php still contains the fix

trasher commented 2 years ago

Yes the file src/Inventory/Asset/InventoryAsset.php still contains the fix

Well, that's another problem then... I've opened a new issue to investigate; I have no idea right now if I can reproduce or not.