You are not logged in.
Pages: 1
Bonjour,
Nous essayons de faire une recherche sur la base de connaissance via l'api des articles ayant le is_faq=1 et nous avons les erreurs ci-dessous:
Requête:
http://(serveur)/apirest.php/search/knowbaseitem?criteria[0][field]=8&criteria[0][searchtype]=equals&criteria[0][value]=1
Résultat:
PHP Notice: Undefined index: rows in /glpi-9.4.4/inc/api.class.php at line 1617
PHP Notice: Undefined index: cols in /glpi-9.4.4/inc/api.class.php at line 1635
PHP Warning: Invalid argument supplied for foreach() in /glpi-9.4.4/inc/api.class.php at line 1635
PHP Notice: Undefined index: rows in /glpi-9.4.4/inc/api.class.php at line 1643
PHP Warning: Invalid argument supplied for foreach() in /glpi-9.4.4/inc/api.class.php at line 1643
{"totalcount":null,"count":0,"sort":1,"order":"ASC","content-range":"0--1/"}
Dans le log sql-errors.log nous avons également ceci
[2019-10-30 09:51:31] glpisqllog.ERROR: DBmysql::query() in /glpi-9.4.4/inc/dbmysql.class.php line 188
*** MySQL query error:
SQL: SELECT DISTINCT `glpi_knowbaseitems`.`id` AS id,
'glpi' AS currentuser,
`glpi_entities`.`completename` AS `ITEM_Knowbaseitem_80`,
`glpi_knowbaseitems`.`is_faq` AS `ITEM_Knowbaseitem_8`
FROM `glpi_knowbaseitems`LEFT JOIN `glpi_entities`
ON (`glpi_knowbaseitems`.`entities_id` = `glpi_entities`.`id`)
WHERE (`glpi_knowbaseitems`.`is_faq` = 1)
ORDER BY `id`
Error: Unknown column 'glpi_knowbaseitems.entities_id' in 'on clause'
Backtrace :
inc/search.class.php:1246
inc/search.class.php:314 Search::constructData()
inc/api.class.php:1606 Search::getDatas()
inc/apirest.class.php:193 API->searchItems()
apirest.php:48 APIRest->call()
{"user":"2@1sad00040"}
La construction de la requête n'est pas correcte et nous rencontrons également ce type d'erreur lors de recherches d'un article en fonction d'une cible (entité, groupe ou profil).
Avez-vous déjà rencontré ce problème ?
Merci
Cordialement
Offline
Bonjour,
L'erreur soumise est liée à la définition rawSearchOptions de la classe KnowbaseItem.
De base en 9.4.4 le champ Entity est défini de la façon suivante :
$tab[] = [
'id' => '80',
'table' => 'glpi_entities',
'field' => 'completename',
'name' => __('Entity'),
'massiveaction' => false,
'datatype' => 'dropdown'
];
Ce qui provoque l'erreur SQL Unknown column 'glpi_knowbaseitems.entities_id' in 'on clause'
En ajoutant une jointure sur ce champ comme indiqué ci-dessous, la requête fonctionne :
$tab[] = [
'id' => '80',
'table' => 'glpi_entities',
'field' => 'completename',
'name' => __('Entity'),
'massiveaction' => false,
'datatype' => 'dropdown',
'joinparams' => [
'beforejoin' => [
'table' => 'glpi_entities_knowbaseitems',
'joinparams' => [
'jointype' => 'child'
]
]
]
];
Pouvez-vous me dire si cette modification est correcte et n'a pas des conséquence sur d'autres fonctions?
Merci
Cordialement
Offline
Si vous essayez de filtrer les demandes du demandeur, cela produit la même erreur: Unknown column 'glpi_users.id' in 'where clause'
La clause "where" n'utilise pas l'alias de la table
SELECT DISTINCT `glpi_tickets`.`id` AS id, 'glpi' AS currentuser, `glpi_tickets`.`id` AS `ITEM_Ticket_2`, `glpi_tickets`.`name` AS `ITEM_Ticket_1`, `glpi_tickets`.`id` AS `ITEM_Ticket_1_id`, `glpi_tickets`.`id` AS `ITEM_Ticket_1_id`, `glpi_tickets`.`content` AS `ITEM_Ticket_1_content`, `glpi_tickets`.`status` AS `ITEM_Ticket_1_status`, `glpi_entities`.`completename` AS `ITEM_Ticket_80`, `glpi_tickets`.`status` AS `ITEM_Ticket_12`, `glpi_tickets`.`date_mod` AS `ITEM_Ticket_19`, `glpi_tickets`.`date` AS `ITEM_Ticket_15`, `glpi_tickets`.`priority` AS `ITEM_Ticket_3`, GROUP_CONCAT(DISTINCT `glpi_users_a5e2026cbcb683e774f93a59e24a62a4`.`id` SEPARATOR '$$##$$') AS `ITEM_Ticket_4`, GROUP_CONCAT(DISTINCT CONCAT(`glpi_tickets_users_d1524bb2ea1d461ab90aed3b5f0e7e60`.`users_id`, ' ', `glpi_tickets_users_d1524bb2ea1d461ab90aed3b5f0e7e60`.`alternative_email`) SEPARATOR '$$##$$') AS `ITEM_Ticket_4_2`, GROUP_CONCAT(DISTINCT `glpi_users_f201be21cd638ee780d08cba4ceff0d4`.`id` SEPARATOR '$$##$$') AS `ITEM_Ticket_5`, GROUP_CONCAT(DISTINCT CONCAT(`glpi_tickets_users_819efb92c8b927b345e489211ec8e43b`.`users_id`, ' ', `glpi_tickets_users_819efb92c8b927b345e489211ec8e43b`.`alternative_email`) SEPARATOR '$$##$$') AS `ITEM_Ticket_5_2`, `glpi_itilcategories`.`completename` AS `ITEM_Ticket_7`, `glpi_tickets`.`time_to_resolve` AS `ITEM_Ticket_18`, `glpi_tickets`.`status` AS `ITEM_Ticket_18_status`, `glpi_users_users_id_recipient`.`name` AS `ITEM_Ticket_22`, `glpi_users_users_id_recipient`.`realname` AS `ITEM_Ticket_22_realname`, `glpi_users_users_id_recipient`.`id` AS `ITEM_Ticket_22_id`, `glpi_users_users_id_recipient`.`firstname` AS `ITEM_Ticket_22_firstname`
FROM `glpi_tickets`
LEFT JOIN `glpi_entities` ON (`glpi_tickets`.`entities_id` = `glpi_entities`.`id` )
LEFT JOIN `glpi_tickets_users` AS `glpi_tickets_users_d1524bb2ea1d461ab90aed3b5f0e7e60` ON (`glpi_tickets`.`id` = `glpi_tickets_users_d1524bb2ea1d461ab90aed3b5f0e7e60`.`tickets_id` AND `glpi_tickets_users_d1524bb2ea1d461ab90aed3b5f0e7e60`.`type` = 1 )
LEFT JOIN `glpi_users` AS `glpi_users_a5e2026cbcb683e774f93a59e24a62a4` ON (`glpi_tickets_users_d1524bb2ea1d461ab90aed3b5f0e7e60`.`users_id` = `glpi_users_a5e2026cbcb683e774f93a59e24a62a4`.`id` )
LEFT JOIN `glpi_tickets_users` AS `glpi_tickets_users_819efb92c8b927b345e489211ec8e43b` ON (`glpi_tickets`.`id` = `glpi_tickets_users_819efb92c8b927b345e489211ec8e43b`.`tickets_id` AND `glpi_tickets_users_819efb92c8b927b345e489211ec8e43b`.`type` = 2 )
LEFT JOIN `glpi_users` AS `glpi_users_f201be21cd638ee780d08cba4ceff0d4` ON (`glpi_tickets_users_819efb92c8b927b345e489211ec8e43b`.`users_id` = `glpi_users_f201be21cd638ee780d08cba4ceff0d4`.`id` )
LEFT JOIN `glpi_itilcategories` ON (`glpi_tickets`.`itilcategories_id` = `glpi_itilcategories`.`id` )
LEFT JOIN `glpi_users` AS `glpi_users_users_id_recipient` ON (`glpi_tickets`.`users_id_recipient` = `glpi_users_users_id_recipient`.`id` )
WHERE `glpi_tickets`.`is_deleted` = 0 AND ( (`glpi_users`.`id` = '7') ) GROUP BY `glpi_tickets`.`id`
ORDER BY ITEM_Ticket_19 DESC
Last edited by javierdehellin (2019-11-28 15:03:00)
Offline
Pages: 1