Skip to content

Commit 9cbbfe7

Browse files
committed
fix(category): bad conversion from raw SQL to quiery builder
1 parent 073c76e commit 9cbbfe7

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

inc/category.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static function getCategoryTree($rootId = 0, $helpdeskHome = false) {
101101
"$form_table.plugin_formcreator_categories_id" => new QueryExpression("$cat_table.id"),
102102
'language' => [$_SESSION['glpilanguage'], '', '0', null],
103103
'OR' => [
104-
'access_rights' => ['!=' => PluginFormcreatorForm::ACCESS_RESTRICTED],
104+
'access_rights' => ['!=', PluginFormcreatorForm::ACCESS_RESTRICTED],
105105
'id' => new QuerySubQuery([
106106
'SELECT' => 'plugin_formcreator_forms_id',
107107
'FROM' => $table_fp,
@@ -116,8 +116,8 @@ public static function getCategoryTree($rootId = 0, $helpdeskHome = false) {
116116
'COUNT' => 'count',
117117
'FROM' => (new QueryExpression("($query_faqs) as faqs")),
118118
'WHERE' => [
119-
"faqs.knowbaseitemcategories_id" => "$cat_table.knowbaseitemcategories_id",
120-
"faqs.knowbaseitemcategories_id" => ['!=' => '0'],
119+
[(new QueryExpression("faqs.knowbaseitemcategories_id = $cat_table.knowbaseitemcategories_id"))],
120+
["faqs.knowbaseitemcategories_id" => ['!=', '0'],],
121121
]
122122
]);
123123
$request = [

tests/suite-unit/PluginFormcreatorCategory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ public function testGetTypeName($nb, $expected) {
6464

6565
public function testGetCategoryTree() {
6666
$this->login('glpi', 'glpi');
67-
$_SESSION["glpicronuserrunning"] = true;
6867

6968
// create a sub entity which will take in the forms and cateory for this test
7069
// and not conflict with previous data
@@ -98,7 +97,7 @@ public function testGetCategoryTree() {
9897
'name' => "testgetCategoryTree form $i",
9998
'entities_id' => $entities_id,
10099
'is_active' => 1,
101-
'is_helpdesk_home' => 1,
100+
'helpdesk_home' => 1,
102101
'plugin_formcreator_categories_id' => $categories[$i]
103102
]);
104103
}

0 commit comments

Comments
 (0)