Skip to content

Commit

Permalink
fix(category): bad conversion from raw SQL to quiery builder
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Aug 22, 2019
1 parent 073c76e commit 9cbbfe7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions inc/category.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static function getCategoryTree($rootId = 0, $helpdeskHome = false) {
"$form_table.plugin_formcreator_categories_id" => new QueryExpression("$cat_table.id"),
'language' => [$_SESSION['glpilanguage'], '', '0', null],
'OR' => [
'access_rights' => ['!=' => PluginFormcreatorForm::ACCESS_RESTRICTED],
'access_rights' => ['!=', PluginFormcreatorForm::ACCESS_RESTRICTED],
'id' => new QuerySubQuery([
'SELECT' => 'plugin_formcreator_forms_id',
'FROM' => $table_fp,
Expand All @@ -116,8 +116,8 @@ public static function getCategoryTree($rootId = 0, $helpdeskHome = false) {
'COUNT' => 'count',
'FROM' => (new QueryExpression("($query_faqs) as faqs")),
'WHERE' => [
"faqs.knowbaseitemcategories_id" => "$cat_table.knowbaseitemcategories_id",
"faqs.knowbaseitemcategories_id" => ['!=' => '0'],
[(new QueryExpression("faqs.knowbaseitemcategories_id = $cat_table.knowbaseitemcategories_id"))],
["faqs.knowbaseitemcategories_id" => ['!=', '0'],],
]
]);
$request = [
Expand Down
3 changes: 1 addition & 2 deletions tests/suite-unit/PluginFormcreatorCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public function testGetTypeName($nb, $expected) {

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

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

0 comments on commit 9cbbfe7

Please sign in to comment.