Skip to content

wrong column names in agent info SQL #98

@swbraun

Description

@swbraun

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

GLPI Version

11.0.7

Plugin version

1.1.2

Bug description

When a computer was generated out of a virtual machine, that was found by glpi-inventory, on this computers "computer tab", there was an alert "unexpected error" instead of the inventory information on the bottom.

Relevant log output

from php_errors.log:

glpi.CRITICAL:   *** Uncaught PHP Exception Twig\Error\RuntimeError: "An exception has been thrown during the rendering of a template ("MySQL query error: Unknown column 'itemtype' in 'WHERE' (1054) in SQL query "SELECT `id` FROM `glpi_assets_assets_peripheralassets` WHERE `itemtype` = 'Computer' AND `items_id` = '21'".") in "components/form/inventory_info.html.twig" at line 181." at inventory_info.html.twig line 181
  Backtrace :
  ...es/components/form/inventory_info.html.twig:181 
  ./vendor/twig/twig/src/Template.php:358            Twig\Template->yield()
  ./vendor/twig/twig/src/Template.php:373            Twig\Template->display()
  ./vendor/twig/twig/src/TemplateWrapper.php:51      Twig\Template->render()
  .../twig/twig/src/Extension/CoreExtension.php:1526 Twig\TemplateWrapper->render()
  ...tes/df/dfd239c8c7abe9186e7a845e35498636.php:162 Twig\Extension\CoreExtension::include()
  ./vendor/twig/twig/src/Template.php:402            __TwigTemplate_d9a4951b7d31392501bd09e1329731ab->doDisplay()
  ./vendor/twig/twig/src/Template.php:358            Twig\Template->yield()
  ./vendor/twig/twig/src/TemplateWrapper.php:61      Twig\Template->display()
  .../Glpi/Application/View/TemplateRenderer.php:188 Twig\TemplateWrapper->display()
  ./src/CommonDBTM.php:551                           Glpi\Application\View\TemplateRenderer->display()
  ./src/CommonGLPI.php:706                           CommonDBTM->showForm()
  ./ajax/common.tabs.php:108                         CommonGLPI::displayStandardTab()
  ...Glpi/Controller/LegacyFileLoadController.php:64 require()
  ./vendor/symfony/http-kernel/HttpKernel.php:181    Glpi\Controller\LegacyFileLoadController->__invoke()
  ./vendor/symfony/http-kernel/HttpKernel.php:76     Symfony\Component\HttpKernel\HttpKernel->handleRaw()
  ./vendor/symfony/http-kernel/Kernel.php:208        Symfony\Component\HttpKernel\HttpKernel->handle()
  ./public/index.php:71                              Symfony\Component\HttpKernel\Kernel->handle()
  Previous: MySQL query error: Unknown column 'itemtype' in 'WHERE' (1054) in SQL query "SELECT `id` FROM `glpi_assets_assets_peripheralassets` WHERE `itemtype` = 'Computer' AND `items_id` = '21'".
  ./src/DBmysql.php:416                              
  ./src/DBmysqlIterator.php:129                      DBmysql->doQuery()
  ./src/DBmysql.php:1088                             DBmysqlIterator->execute()
  ./src/CommonDBTM.php:429                           DBmysql->request()
  ...baseinventory/inc/inventoryaction.class.php:149 CommonDBTM->getFromDBByCrit()
  ...baseinventory/inc/inventoryaction.class.php:181 PluginDatabaseinventoryInventoryAction::findAgent()
  ./marketplace/databaseinventory/hook.php:111       PluginDatabaseinventoryInventoryAction::postItemForm()
  ./src/Plugin.php:1810                              postItemForm()
  ...plication/View/Extension/PluginExtension.php:74 Plugin::doHook()
  ...tes/f3/f38a33e38fd99273005fa14dfe6bbd85.php:320 Glpi\Application\View\Extension\PluginExtension->callPluginHook()
  ./vendor/twig/twig/src/Template.php:402            __TwigTemplate_7587614a72903d41ff18a7366e820481->doDisplay()
  ./vendor/twig/twig/src/Template.php:358            Twig\Template->yield()
  ./vendor/twig/twig/src/Template.php:373            Twig\Template->display()
  ./vendor/twig/twig/src/TemplateWrapper.php:51      Twig\Template->render()
  .../twig/twig/src/Extension/CoreExtension.php:1526 Twig\TemplateWrapper->render()
  ...tes/df/dfd239c8c7abe9186e7a845e35498636.php:162 Twig\Extension\CoreExtension::include()
  ./vendor/twig/twig/src/Template.php:402            __TwigTemplate_d9a4951b7d31392501bd09e1329731ab->doDisplay()
  ./vendor/twig/twig/src/Template.php:358            Twig\Template->yield()
  ./vendor/twig/twig/src/TemplateWrapper.php:61      Twig\Template->display()
  .../Glpi/Application/View/TemplateRenderer.php:188 Twig\TemplateWrapper->display()
  ./src/CommonDBTM.php:551                           Glpi\Application\View\TemplateRenderer->display()
  ./src/CommonGLPI.php:706                           CommonDBTM->showForm()
  ./ajax/common.tabs.php:108                         CommonGLPI::displayStandardTab()
  ...Glpi/Controller/LegacyFileLoadController.php:64 require()
  ./vendor/symfony/http-kernel/HttpKernel.php:181    Glpi\Controller\LegacyFileLoadController->__invoke()
  ./vendor/symfony/http-kernel/HttpKernel.php:76     Symfony\Component\HttpKernel\HttpKernel->handleRaw()
  ./vendor/symfony/http-kernel/Kernel.php:208        Symfony\Component\HttpKernel\HttpKernel->handle()
  ./public/index.php:71                              Symfony\Component\HttpKernel\Kernel->handle()

Page URL

http://glpi/front/computer.form.php?id=21

Steps To reproduce

installed plugins:

  • glpi inventory
  • database inventory

configure inventory, so that it creates "computers" out of virtual machines

run glpi agent an a proxmox host -> for every VM a computer is created inside glpi
open newly created "vm computer", on bottom of "computer" tab, there is an unexpected error

Your GLPI setup information

GLPI information
GLPI: 11.0.7 ( => /opt/glpi)
Installation mode: TARBALL
Current language: de_DE
Source Integrity: 1 files changed
  A: inc/downstream.php
Server
Operating system: Linux glpi 6.8.12-18-pve #​1 SMP PREEMPT_DYNAMIC PMX 6.8.12-18 (2025-12-15T18:07Z) x86_64

PHP: 8.4.16 apache2handler

PHP extensions: Core, date, libxml, openssl, pcre, zlib, filter, hash, json, random, Reflection, SPL, session, standard, sodium, apache2handler, mysqlnd, PDO, xml, apcu, bcmath, bz2, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, iconv, igbinary, intl, ldap, exif, mcrypt, mysqli, pdo_mysql, Phar, posix, readline, shmop, SimpleXML, soap, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, xmlreader, xmlrpc, xmlwriter, xsl, zip, redis, Zend OPcache

Setup: disable_functions="" max_execution_time="60" max_input_vars="1000" memory_limit="256M" post_max_size="20M" session.cookie_secure="0" session.cookie_httponly="1" session.cookie_samesite="" session.save_handler="files" upload_max_filesize="20M"

Web server: Apache/2.4.66 (Debian) (Apache/2.4.66 (Debian) Server at glpi Port 80)

User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:150.0) Gecko/20100101 Firefox/150.0

Database:

Server Software: -- Please help get to 10k stars at https://github.com/MariaDB/Server

Server Version: 11.8.6-MariaDB-0+deb13u1 from Debian

Server SQL Mode: STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Parameters: glpi@localhost/glpi_db

Host info: Localhost via UNIX socket

Requirements:
PHP version (8.4.16) is supported.
OS and PHP are relying on 64 bits integers.
Sessions configuration is OK.
Allocated memory is sufficient.
Following extensions are installed: dom, fileinfo, filter, libxml, simplexml, tokenizer, xmlreader, xmlwriter.
mysqli extension is installed
curl extension is installed
gd extension is installed
intl extension is installed
mbstring extension is installed
zlib extension is installed
bcmath extension is installed
The constant SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES is present.
openssl extension is installed
Database engine version (11.8.6) is supported.
The log file has been created successfully.
Write access to /var/lib/glpi/_cache has been validated.
Write access to /var/lib/glpi/_cron has been validated.
Write access to /var/lib/glpi has been validated.
Write access to /var/lib/glpi/_graphs has been validated.
Write access to /var/lib/glpi/_lock has been validated.
Write access to /var/lib/glpi/_pictures has been validated.
Write access to /var/lib/glpi/_plugins has been validated.
Write access to /var/lib/glpi/_rss has been validated.
Write access to /var/lib/glpi/_sessions has been validated.
Write access to /var/lib/glpi/_tmp has been validated.
Write access to /var/lib/glpi/_uploads has been validated.

Sessions configuration is secured.
exif extension is installed
ldap extension is installed
Following extensions are installed: bz2, Phar, zip.
Zend OPcache extension is installed
Following extensions are installed: ctype, iconv, sodium.
Write access to /opt/glpi/marketplace has been validated.
Timezones seems loaded in database.


GLPI constants

GLPI_ROOT: "/opt/glpi"
GLPI_VERSION: "11.0.7"
GLPI_SCHEMA_VERSION: "11.0.7@a797be2bef86f3888448b141fa810dba6fb67795"
GLPI_FILES_VERSION: "11.0.7-49a93008"
GLPI_MIN_PHP: "8.2"
GLPI_MAX_PHP: "8.5"
GLPI_YEAR: "2026"
GLPI_I18N_DIR: "/opt/glpi/locales"
GLPI_CONFIG_DIR: "/etc/glpi/"
GLPI_VAR_DIR: "/var/lib/glpi"
GLPI_DOC_DIR: "/var/lib/glpi"
GLPI_CRON_DIR: "/var/lib/glpi/_cron"
GLPI_DUMP_DIR: "/var/lib/glpi/_dumps"
GLPI_GRAPH_DIR: "/var/lib/glpi/_graphs"
GLPI_LOCK_DIR: "/var/lib/glpi/_lock"
GLPI_PICTURE_DIR: "/var/lib/glpi/_pictures"
GLPI_PLUGIN_DOC_DIR: "/var/lib/glpi/_plugins"
GLPI_RSS_DIR: "/var/lib/glpi/_rss"
GLPI_SESSION_DIR: "/var/lib/glpi/sessions"
GLPI_TMP_DIR: "/var/lib/glpi/tmp"
GLPI_UPLOAD_DIR: "/var/lib/glpi/uploads"
GLPI_CACHE_DIR: "/var/lib/glpi/cache"
GLPI_LOG_DIR: "/var/log/glpi"
GLPI_ENVIRONMENT_TYPE: "production"
GLPI_MARKETPLACE_DIR: "/opt/glpi/marketplace"
GLPI_ALLOW_IFRAME_IN_RICH_TEXT: false
GLPI_SERVERSIDE_URL_ALLOWLIST: ["~^\n (http|https|feed):// # protocol\n (\n (?:\n (?:xn--[a-z0-9-]++\.)*+xn--[a-z0-9-]++ # a domain name using punycode\n |\n (?:[\pL\pN\pS\pM\-\
]++\.)+[\pL\pN\pM]++ # a multi-level domain name\n |\n [a-z0-9\-\
]++ # a single-level domain name\n )\.?\n | # or\n \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # an IP address\n | # or\n \[\n (?:(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){6})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:::(?:(?:(?:[0-9a-f]{1,4})):){5})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){4})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,1}(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){3})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,2}(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){2})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,3}(?:(?:[0-9a-f]{1,4})))?::(?:(?:[0-9a-f]{1,4})):)(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,4}(?:(?:[0-9a-f]{1,4})))?::)(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,5}(?:(?:[0-9a-f]{1,4})))?::)(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,6}(?:(?:[0-9a-f]{1,4})))?::))))\n \] # an IPv6 address\n )\n (?:/ (?:[\pL\pN\pS\pM\-.
\~!$&'()+,;=:@]|%[0-9A-Fa-f]{2}) )* # a path\n (?:\? (?:[\pL\pN\-.
\~!$&'\\+,;=:@/?]|%[0-9A-Fa-f]{2}) )? # a query (optional)\n $~ixuD"]
GLPI_DISALLOWED_UPLOADS_PATTERN: "/\.(php\d*|phar)$/i"
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_ENABLE: 3
GLPI_MARKETPLACE_PRERELEASES: false
GLPI_MARKETPLACE_ALLOW_OVERRIDE: true
GLPI_MARKETPLACE_MANUAL_DOWNLOADS: true
GLPI_USER_AGENT_EXTRA_COMMENTS: ""
GLPI_DOCUMENTATION_ROOT_URL: "https://links.glpi-project.org"
GLPI_DISABLE_ONLY_FULL_GROUP_BY_SQL_MODE: "1"
GLPI_LOG_LVL: "warning"
GLPI_SKIP_UPDATES: false
GLPI_STRICT_ENV: false
GLPI_AJAX_DASHBOARD: "1"
GLPI_CALDAV_IMPORT_STATE: 0
GLPI_CENTRAL_WARNINGS: "1"
GLPI_SYSTEM_CRON: false
GLPI_TEXT_MAXSIZE: "4000"
GLPI_WEBHOOK_ALLOW_RESPONSE_SAVING: "0"
GLPI_WEBHOOK_CRA_MANDATORY: false
GLPI_ALTCHA_MODE: "interactive"
GLPI_ALTCHA_MAX_NUMBER: 50000
GLPI_ALTCHA_EXPIRATION_INTERVAL: "PT20M"
GLPI_LOCAL_I18N_DIR: "/var/lib/glpi/_locales"
GLPI_INVENTORY_DIR: "/var/lib/glpi/_inventories"
GLPI_THEMES_DIR: "/var/lib/glpi/_themes"
GLPI_PLUGINS_DIRECTORIES: ["/opt/glpi/marketplace","/opt/glpi/plugins"]
GLPI_NETWORK_API_URL: "https://services.glpi-network.com/api"
GLPI_NETWORK_REGISTRATION_API_URL: "https://services.glpi-network.com/api/registration/"
GLPI_MARKETPLACE_PLUGINS_API_URI: "https://services.glpi-network.com/api/marketplace/"

SQL replicas

Not active

Notifications

Way of sending emails: SMTP(smtp://ww8459p1:********@rw08.serverdomain.org:25)

Plugins list

accounts Name: Accounts Version: 3.2.1 State: Enabled Install Method: Marketplace
connections Name: Connections Version: 11.0.4 State: Enabled Install Method: Marketplace
databaseinventory Name: Database inventory Version: 1.1.2 State: Enabled Install Method: Marketplace
glpiinventory Name: GLPI Inventory Version: 1.6.7 State: Enabled Install Method: Marketplace
addressing Name: IP Report Version: 3.2.0 State: Enabled Install Method: Marketplace
additionalalerts Name: Additional Alerts Version: 3.0.3 State: Installed / not activated Install Method: Marketplace

Anything else?

I found out the problem is two wrong column names in the file "inc/inventoryaction.class.php"
in function findAgent()

I changed following lines:
150 to: 'itemtype_asset' => $item->getType(),
151 to: 'items_id_asset' => $item->fields['id'],
155 to: 'itemtype_asset' => Computer::getType(),
156 to: 'items_id_asset' => $citem->fields['computers_id'],

after that change, the error vanished.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions