You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2023-11-11 15:28:45

ilbicelli
Member
Registered: 2022-11-21
Posts: 15

Credit Vouchers error after upgrade to 1.13.0

Hello,
running GLPI 10.0.10, updated Credit vouchers to latest release (1.13.0).

After any action on ticket I get blank page and in php_error.log appears:

[2023-11-11 13:21:29] glpiphplog.CRITICAL:   *** Uncaught Exception RuntimeException: Invalid field name         SELECT
            `glpi_plugin_credit_entities`.`name`,
            `glpi_plugin_credit_entities`.`quantity`,
            (SELECT SUM(`glpi_plugin_credit_tickets`.`consumed`) FROM `glpi_plugin_credit_tickets` WHERE `glpi_plugin_credit_tickets`.`plugin_credit_entities_id` = `glpi_plugin_credit_entities`.`id` AND `glpi_plugin_credit_tickets`.`tickets_id` = 0000115) AS `consumed_on_ticket`,
            (SELECT SUM(`glpi_plugin_credit_tickets`.`consumed`) FROM `glpi_plugin_credit_tickets` WHERE `glpi_plugin_credit_tickets`.`plugin_credit_entities_id` = `glpi_plugin_credit_entities`.`id`) AS  `consumed_total`
        FROM `glpi_plugin_credit_entities`
        WHERE `is_active`=1 and `entities_id`=0 in /var/www/glpi/src/DBmysql.php at line 1250
  Backtrace :
  src/DBmysqlIterator.php:288                        DBmysql::quoteName()
  src/DBmysqlIterator.php:111                        DBmysqlIterator->buildQuery()
  src/DBmysql.php:1078                               DBmysqlIterator->execute()
  marketplace/credit/hook.php:134                    DBmysql->request()
  src/Plugin.php:1665                                plugin_credit_get_datas()
  src/NotificationTarget.php:1365                    Plugin::doHook()
  src/NotificationTemplate.php:278                   NotificationTarget->getForTemplate()
  src/NotificationEventAbstract.php:122              NotificationTemplate->getTemplateByLanguage()
  src/NotificationEvent.php:187                      NotificationEventAbstract::raise()
  src/ITILFollowup.php:284                           NotificationEvent::raiseEvent()
  src/CommonDBTM.php:1324                            ITILFollowup->post_addItem()
  front/itilfollowup.form.php:55                     CommonDBTM->add()
  public/index.php:82                                require()

Strangely, running query in MariaDB:

MariaDB [glpi]> SELECT
    ->             `glpi_plugin_credit_entities`.`name`,
    ->             `glpi_plugin_credit_entities`.`quantity`,
    ->             (SELECT SUM(`glpi_plugin_credit_tickets`.`consumed`) FROM `glpi_plugin_credit_tickets` WHERE `glpi_plugin_credit_tickets`.`plugin_credit_entities_id` = `glpi_plugin_credit_entities`.`id` AND `glpi_plugin_credit_tickets`.`tickets_id` = 0000115) AS `consumed_on_ticket`,
    ->             (SELECT SUM(`glpi_plugin_credit_tickets`.`consumed`) FROM `glpi_plugin_credit_tickets` WHERE `glpi_plugin_credit_tickets`.`plugin_credit_entities_id` = `glpi_plugin_credit_entities`.`id`) AS  `consumed_total`
    ->         FROM `glpi_plugin_credit_entities`
    ->         WHERE `is_active`=1 and `entities_id`=0;
Empty set (0.001 sec)

Last edited by ilbicelli (2023-11-11 15:43:03)

Offline

#2 2023-11-13 01:44:47

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,809
Website

Re: Credit Vouchers error after upgrade to 1.13.0

The query itself isn't the issue. It seems odd that the issue started after the plugin update. It seems like the issue is with GLPI mistaking an entire SQL query as just a table name and it tries to escape it as such.
Ideally, the plugin should be fixed to stop using raw SQL queries completely since that is the old method anyways.

If I have time tomorrow, I'll see if I can make a pull request on the plugin's GitHub page.


GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.

Offline

#3 2023-11-16 12:04:37

workingr
Member
Registered: 2023-11-16
Posts: 2

Re: Credit Vouchers error after upgrade to 1.13.0

Same error after i updated it.

Offline

#4 2023-11-16 13:59:27

workingr
Member
Registered: 2023-11-16
Posts: 2

Re: Credit Vouchers error after upgrade to 1.13.0

My colleague found the issue.

Inside src:

    //handle aliases
        $names = preg_split('/\s+AS\s+/i', $name);
        if (count($names) > 2) {
            throw new \RuntimeException(
                'Invalid field name ' . $name
            );
        }

The parameter 'AS' in the Select appearing on php_error.log (AS  `consumed_on_ticket`) and (AS `consumed_total`), is what causing this exception to be actioned. We simply removed it and it worked!

Offline

#5 2023-11-16 15:32:50

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,809
Website

Re: Credit Vouchers error after upgrade to 1.13.0

The fix will be part of version 1.13.1 of the plugin.
https://github.com/pluginsGLPI/credit/pull/107


GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.

Offline

Board footer

Powered by FluxBB