Describe the bug
Hi all,
We've upgraded our GLPI version from v9.4.5 to 9.5.2 but had to rollback because of an error reportly caused by Business Rules for Tickets (ruleticket)
Might be related to #8232
After the update, everything seemed to be working correctly but I found that once activating the cron job for mailcollectors, the action stayed stuck running...
I manually stopped it and runned it again but was presented this error :

The php-errors.log didn't gave really much more clue on the error :

And sql-errors.log didn't had anything meaningful in it.
After lors of troubleshooting and running on this forum question bellow (not the same contect but the same error messages), I finally found that the problem was coming from one of our business rule for ticket
https://forum.glpi-project.org/viewtopic.php?pid=481001#p481001
The business rule is the following :
I tried changed it to "Category - Name Does not exist" but that didn't work
Disabling this rules compleatly worked
I don't see why this rule would make it crash but it does.... Now that it's disabled, mailcollectors are working correctly.
Unfortunately, there seems to be other business rules that affects the formcreator plugins in the same way as it throw the same error message when submitting the form and creating the tickets...
I know you don't support plugins directly but since it affect the whole glpi, I thing the bug is somewhere in the core functions of the ruleticket class....
Page(s) URL
https://REDACTED/glpi/front/mailcollector.form.php?id=7
https://REDACTED/glpi/marketplace/formcreator/front/formdisplay.php?id=1
https://REDACTED/glpi/front/crontask.form.php?id=9
To reproduce
Enabling the affected business rule for ticket and create a ticket from mailcollector or formcreator plugins.
Expected behavior
Processing correctly the business rules and creating the ticket
Screenshots







Your GLPI setup (you can find it in Setup > General menu, System tab)
Operating system: Linux glpi05 2.6.32-042stab131.1 #1 SMP Wed Jun 20 16:32:07 MSK 2018 x86_64 PHP 7.2.34 apache2handler (Core, PDO, Phar, Reflection, SPL, SimpleXML, Zend OPcache, apache2handler, apcu, bcmath, bz2, calendar, ctype, curl, date, dom, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, imap, intl, json, ldap, libxml, mbstring, memcache, mysqli, mysqlnd, openssl, pcre, pdo_dblib, pdo_mysql, pdo_sqlite, pdo_sqlsrv, posix, session, shmop, soap, sockets, sodium, sqlite3, sqlsrv, standard, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib) Setup: max_execution_time="30" memory_limit="256M" post_max_size="8M" safe_mode="" session.save_handler="files" upload_max_filesize="8M" Software: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.34 () Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36 Server Software: Source distribution Server Version: 8.0.21 Server SQL Mode: Parameters: glpi@REDACTED_INFO/glpi Host info: REDACTED_INFO via TCP/IP PHP version is at least 7.2.0 - Perfect! Sessions support is available - Perfect! Allocated memory > 64 Mio - Perfect! mysqli extension is installed ctype extension is installed fileinfo extension is installed json extension is installed mbstring extension is installed iconv extension is installed zlib extension is installed curl extension is installed gd extension is installed simplexml extension is installed intl extension is installed ldap extension is installed apcu extension is installed Zend OPcache extension is installed xmlrpc extension is installed CAS extension is installed exif extension is installed zip extension is installed bz2 extension is installed sodium extension is installed Database version seems correct (8.0.21) - Perfect! Timezones seems loaded in database The log file has been created successfully. Write access to /var/www/glpiData/config/ 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/_sessions has been validated. Write access to /var/www/glpiData/files/_cron 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/_plugins has been validated. Write access to /var/www/glpiData/files/_tmp has been validated. Write access to /var/www/glpiData/files/_cache has been validated. Write access to /var/www/glpiData/files/_rss has been validated. Write access to /var/www/glpiData/files/_uploads has been validated. Write access to /var/www/glpiData/files/_pictures has been validated. Write access to /var/www/html/glpi-9.5.2/marketplace has been validated.
GLPI_ROOT: /var/www/html/glpi-9.5.2 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-9.5.2/marketplace GLPI_USE_CSRF_CHECK: 1 GLPI_CSRF_EXPIRES: 7200 GLPI_CSRF_MAX_TOKENS: 100 GLPI_TELEMETRY_URI: https://telemetry.glpi-project.org GLPI_INSTALL_MODE: TARBALL GLPI_NETWORK_MAIL: [email protected] 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/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_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-9.5.2/locales GLPI_VERSION: 9.5.2 GLPI_SCHEMA_VERSION: 9.5.2 GLPI_MIN_PHP: 7.2.0 GLPI_YEAR: 2020
htmlawed/htmlawed version 1.2.5 in (/var/www/html/glpi-9.5.2/vendor/htmlawed/htmlawed) phpmailer/phpmailer version 6.1.6 in (/var/www/html/glpi-9.5.2/vendor/phpmailer/phpmailer/src) simplepie/simplepie version 1.5.5 in (/var/www/html/glpi-9.5.2/vendor/simplepie/simplepie/library) tecnickcom/tcpdf version 6.3.5 in (/var/www/html/glpi-9.5.2/vendor/tecnickcom/tcpdf) michelf/php-markdown in (/var/www/html/glpi-9.5.2/vendor/michelf/php-markdown/Michelf) true/punycode in (/var/www/html/glpi-9.5.2/vendor/true/punycode/src) iamcal/lib_autolink in (/var/www/html/glpi-9.5.2/vendor/iamcal/lib_autolink) sabre/dav in (/var/www/html/glpi-9.5.2/vendor/sabre/dav/lib/DAV) sabre/http in (/var/www/html/glpi-9.5.2/vendor/sabre/http/lib) sabre/uri in (/var/www/html/glpi-9.5.2/vendor/sabre/uri/lib) sabre/vobject in (/var/www/html/glpi-9.5.2/vendor/sabre/vobject/lib) laminas/laminas-cache in (/var/www/html/glpi-9.5.2/vendor/laminas/laminas-cache/src) laminas/laminas-i18n in (/var/www/html/glpi-9.5.2/vendor/laminas/laminas-i18n/src) laminas/laminas-serializer in (/var/www/html/glpi-9.5.2/vendor/laminas/laminas-serializer/src) monolog/monolog in (/var/www/html/glpi-9.5.2/vendor/monolog/monolog/src/Monolog) sebastian/diff in (/var/www/html/glpi-9.5.2/vendor/sebastian/diff/src) elvanto/litemoji in (/var/www/html/glpi-9.5.2/vendor/elvanto/litemoji/src) symfony/console in (/var/www/html/glpi-9.5.2/vendor/symfony/console) scssphp/scssphp in (/var/www/html/glpi-9.5.2/vendor/scssphp/scssphp/src) laminas/laminas-mail in (/var/www/html/glpi-9.5.2/vendor/laminas/laminas-mail/src/Protocol) laminas/laminas-mime in (/var/www/html/glpi-9.5.2/vendor/laminas/laminas-mime/src) rlanvin/php-rrule in (/var/www/html/glpi-9.5.2/vendor/rlanvin/php-rrule/src) blueimp/jquery-file-upload in (/var/www/html/glpi-9.5.2/vendor/blueimp/jquery-file-upload/server/php) ramsey/uuid in (/var/www/html/glpi-9.5.2/vendor/ramsey/uuid/src) psr/log in (/var/www/html/glpi-9.5.2/vendor/psr/log/Psr/Log) psr/simple-cache in (/var/www/html/glpi-9.5.2/vendor/psr/simple-cache/src) mexitek/phpcolors in (/var/www/html/glpi-9.5.2/vendor/mexitek/phpcolors/src/Mexitek/PHPColors) guzzlehttp/guzzle in (/var/www/html/glpi-9.5.2/vendor/guzzlehttp/guzzle/src) guzzlehttp/psr7 in (/var/www/html/glpi-9.5.2/vendor/guzzlehttp/psr7/src) wapmorgan/unified-archive in (/var/www/html/glpi-9.5.2/vendor/wapmorgan/unified-archive/src) paragonie/sodium_compat in (/var/www/html/glpi-9.5.2/vendor/paragonie/sodium_compat/src) phpCas version 1.3.6 in (/usr/share/pear)
Server: 'REDACTED_INFO', Port: '389', BaseDN: 'dc=REDACTED_INFO', Connection filter: '(&(&(objectClass=user)(objectCategory=person)(!(userAccountControl:1.2.840.113556.1.4.803:=514))(!(userAccountControl:1.2.840.113556.1.4.803:=546))(!(userAccountControl:1.2.840.113556.1.4.803:=66050))(!(userAccountControl:1.2.840.113556.1.4.803:=66082)))(\|(samaccountname=e)(samaccountname=m)(samaccountname=o)(samaccountname=t)(samaccountname=garde)(samaccountname=ressources.materiell)))', RootDN: 'REDACTED_INFO', Use TLS: none
Not active
Way of sending emails: SMTP (anonymous@localhost)
Name: 'REDACTED_INFO' Active: No Server: '{outlook.office365.com/imap/ssl}' Login: 'REDACTED_INFO' Password: Yes Name: 'REDACTED_INFO' Active: No Server: '{outlook.office365.com/imap/ssl}' Login: 'REDACTED_INFO' Password: Yes Name: 'REDACTED_INFO' Active: No Server: '{outlook.office365.com/imap/ssl}' Login: 'REDACTED_INFO' Password: Yes Name: 'REDACTED_INFO' Active: No Server: '{outlook.office365.com/imap/ssl}' Login: 'REDACTED_INFO' Password: Yes Name: 'REDACTED_INFO' Active: No Server: '{outlook.office365.com/imap/ssl}' Login: 'REDACTED_INFO' Password: Yes Name: 'REDACTED_INFO' Active: Yes Server: '{outlook.office365.com/imap/ssl}' Login: 'REDACTED_INFO' Password: Yes
advancedplanning Name: advancedplanning Version: 0.2.0 State: Enabled news Name: Alertes Version: 1.8.0 State: Enabled treeview Name: Arborescence Version: 1.9.0 State: Enabled fields Name: Champs suppl茅mentaires Version: 1.12.0 State: Enabled datainjection Name: Data Injection Version: 2.8.1 State: Enabled formcreator Name: Form Creator Version: 2.10.3 State: Enabled fusioninventory Name: FusionInventory Version: 9.5.0+1.0 State: Enabled genericobject Name: Gestion d'objets Version: 2.9.1 State: Enabled order Name: Gestion des commandes Version: 2.6.0 State: Enabled manufacturersimports Name: Imports fabricants Version: 2.3.0 State: Enabled taskdrop Name: TaskDrop Version: 1.2.0 State: Enabled
[/code]
Hi,
1) Can you try to reproduce the mailcollector failure with no active plugin ?
2) Can you try with current nightly build ?
3) If problem persis, can you apply following patch andd check log output ?
diff --git a/inc/rulecriteria.class.php b/inc/rulecriteria.class.php
index 04bd46c199..a8e9581c66 100644
--- a/inc/rulecriteria.class.php
+++ b/inc/rulecriteria.class.php
@@ -385,6 +385,9 @@ class RuleCriteria extends CommonDBChild {
case Rule::PATTERN_UNDER :
$table = getTableNameForForeignKeyField($criteria);
+ if (empty($table)) {
+ Toolbox::logWarning(sprintf('Unable to compute table namefor criteria "%s".', $criteria));
+ }
$values = getSonsOf($table, $pattern);
if (isset($values[$field])) {
return true;
I tried to reproduce on my side, but mailcollector was working as expected (I had no active plugin).
Regards
By the way, your log seems not directly related to the mentionned rule. Indded, your rule uses a is condition, but the log is related to a under condition.
With all plugins desactivated, the error is still present. I'll try the nightly build after ma backup to see if it changes the outcome ;)
P.S. The PHP User Warning I get before the PHP User Error seems to pass an empty $table variable as table name in the "fieldExists" function...
trigger_error("Table $table does not exists", E_USER_WARNING); //Should include the table name missing...
PHP User Warning (512): Table does not exists in /var/www/html/glpi-9.5.2/inc/dbmysql.class.php at line 1009 //Does not...
P.S. The PHP User Warning I get before the PHP User Error seems to pass an empty $table variable as table name in the "fieldExists" function...
This is exactly the reason I produce the patch mentionned on my previous comment. It is nearly impossible to debug without it.
The function probably get called from another condition because I get the same message with this :


Debug message will appear in GLPI log files, not in UI.
Ohhh I see. Now where getting somewhere :)

What's really weird is that
I according to the log warning, the "users_locations" criteria is triggering the error, but that condition is in about 40 active rules like the following :

But the rule that make the mailcollectors works when I disable it does not contains that condition :

Hi,
I found what is the source of the issue. Short explaination is that some criteria are failing when using under and not under. The failing rule is evaluated when your rule Assigner les sans-cat茅gories 脿 STI is active it assign the category Service des technologies.
Technical explaination is that the criteria users_locations (Requester location) does not respect the foreign key pattern, and should be renamed to locations_id_users. It requires a renaming in the source code and a database update.
This issue affects (at least):
GROUPS (Group)users_locations (Requester location)items_locations (Item location)items_groups (Item group)items_states (Item state)GROUPS (User: Group)I guess the fix should be global, and a unit test should be added to check that criterias of type dropdown have identifier that matches foreign key pattern for their table value.
As this fix require lots of work, it may not be available soon. Maybe you should consider changing your rules to not use a under/not under match on these criteria.
Regards
Wow, thanks for the detailed explanation. I'll try changing the rules conditions to IS or IS-NOT tomorrow to see if It can works around the bug for now.
Your help was really appreciated :)
Confirmed : When changing those rules to use the "contains" condition instead of "under", the mailgate and creation of tickets are working as they should.
Thanks
Hi, please test #8256 and give us feedback.
I'll give a try today and report back. Thanks
Confirmed working 馃憤
Might sound like a stupid question but if I have to put it in production environment, should I :
If I apply the bugfixes and change to version 9.5.3, what yould be the easiest way to update to official releases in the future? Reapply all the new bugfixes before updating?
Thanks and sorry for the weird question
Francois
Thanks for the feedback.
To answer your question, the safer solution would be not to change GLPI code and use the workaround until 9.5.3 has been released.
Yes, applying the patch or switching to 9.5/bf branch (when it'll get merged) will switch your DB version to 9.5.3.
Using a specific patch (when it applies) or the current bugfixes branch would solve your issue; but that way you will be using a "development" version that may ends with small update issues (if another fix makes changes in the database for example).
While possible, you'd rather keep the stable version in production if you have doubts.
what yould be the easiest way to update to official releases in the future?
The same as standard update I guess, but you may have to force the database update (only possible from cli): that is difficult to say since we're not close to a new release and we have no idea which other changes may be included :)