Skip to content

Commit f818178

Browse files
committed
fix: compatibility with GLPI 9.5
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent 6eb2bb8 commit f818178

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

inc/category.class.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ public static function getCategoryTree($rootId = 0, $helpdeskHome = false) {
9292
'faq' => '1',
9393
'contains' => ''
9494
]);
95+
if (version_compare(GLPI_VERSION, "9.4") > 0) {
96+
// GLPI 9.5 returns an array
97+
$subQuery = new DBMysqlIterator($DB);
98+
$subQuery->buildQuery($query_faqs);
99+
$query_faqs = $subQuery->getSQL();
100+
}
95101

96102
// Selects categories containing forms or sub-categories
97103
$categoryFk = self::getForeignKeyField();

inc/form.class.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -907,13 +907,19 @@ public function showFormList($rootCategory = 0, $keywords = '', $helpdeskHome =
907907
}
908908

909909
// Find FAQ entries
910-
$query_faqs = new QueryExpression('(' . KnowbaseItem::getListRequest([
911-
'faq' => '1',
912-
'contains' => $keywords
913-
]) . ') AS `faqs`');
910+
$query_faqs = KnowbaseItem::getListRequest([
911+
'faq' => '1',
912+
'contains' => $keywords
913+
]);
914+
if (version_compare(GLPI_VERSION, "9.4") > 0) {
915+
$subQuery = new DBMysqlIterator($DB);
916+
$subQuery->buildQuery($query_faqs);
917+
$query_faqs = '(' . $subQuery->getSQL() . ') AS `faqs`';
918+
}
919+
914920
$query_faqs = [
915921
'SELECT' => ['faqs' => '*'],
916-
'FROM' => $query_faqs,
922+
'FROM' => new QueryExpression('(' . $query_faqs . ') AS `faqs`'),
917923
];
918924
if (count($selectedCategories) > 0) {
919925
$query_faqs['WHERE'] = [

0 commit comments

Comments
 (0)