Skip to content

Commit

Permalink
fix: compatibility with GLPI 9.5
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Nov 1, 2019
1 parent 6eb2bb8 commit f818178
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 6 additions & 0 deletions inc/category.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ public static function getCategoryTree($rootId = 0, $helpdeskHome = false) {
'faq' => '1',
'contains' => ''
]);
if (version_compare(GLPI_VERSION, "9.4") > 0) {
// GLPI 9.5 returns an array
$subQuery = new DBMysqlIterator($DB);
$subQuery->buildQuery($query_faqs);
$query_faqs = $subQuery->getSQL();
}

// Selects categories containing forms or sub-categories
$categoryFk = self::getForeignKeyField();
Expand Down
16 changes: 11 additions & 5 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -907,13 +907,19 @@ public function showFormList($rootCategory = 0, $keywords = '', $helpdeskHome =
}

// Find FAQ entries
$query_faqs = new QueryExpression('(' . KnowbaseItem::getListRequest([
'faq' => '1',
'contains' => $keywords
]) . ') AS `faqs`');
$query_faqs = KnowbaseItem::getListRequest([
'faq' => '1',
'contains' => $keywords
]);
if (version_compare(GLPI_VERSION, "9.4") > 0) {
$subQuery = new DBMysqlIterator($DB);
$subQuery->buildQuery($query_faqs);
$query_faqs = '(' . $subQuery->getSQL() . ') AS `faqs`';
}

$query_faqs = [
'SELECT' => ['faqs' => '*'],
'FROM' => $query_faqs,
'FROM' => new QueryExpression('(' . $query_faqs . ') AS `faqs`'),
];
if (count($selectedCategories) > 0) {
$query_faqs['WHERE'] = [
Expand Down

0 comments on commit f818178

Please sign in to comment.