Skip to content

Commit b63afc1

Browse files
stonebuzzRom1-B
andauthored
Fix(search): fix tag search criteria (#317)
* Fix(search): fix tag search criteria * remove useless debug Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com> * remove useless debug Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com> * add missing table --------- Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com>
1 parent e87ded3 commit b63afc1

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [UNRELEASED]
9+
10+
### Fixed
11+
12+
- Fix tag search
13+
14+
815
## [2.14.2] - 2025-12-02
916

1017
### Fixed

hook.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,16 @@ function plugin_tag_getAddSearchOptionsNew($itemtype)
9797
'searchtype' => ['equals','notequals','contains'],
9898
'massiveaction' => false,
9999
'forcegroupby' => true,
100+
'usehaving' => true,
100101
'joinparams' => [
101102
'beforejoin' => [
102103
'table' => 'glpi_plugin_tag_tagitems',
103104
'joinparams' => [
104105
'jointype' => 'itemtype_item',
106+
'specific_itemtype' => $itemtype,
107+
'beforejoin' => [
108+
'table' => getTableForItemType($itemtype),
109+
],
105110
],
106111
],
107112
],
@@ -172,7 +177,7 @@ function plugin_tag_giveItem($type, $field, $data, $num, $linkfield = "")
172177

173178
function plugin_tag_addHaving($link, $nott, $itemtype, $id, $val, $num)
174179
{
175-
$searchopt = &Search::getOptions($itemtype);
180+
$searchopt = Search::getOptions($itemtype);
176181
$table = $searchopt[$id]["table"];
177182
$field = $searchopt[$id]["field"];
178183

@@ -193,7 +198,7 @@ function plugin_tag_addHaving($link, $nott, $itemtype, $id, $val, $num)
193198

194199
function plugin_tag_addWhere($link, $nott, $itemtype, $id, $val, $searchtype)
195200
{
196-
$searchopt = &Search::getOptions($itemtype);
201+
$searchopt = Search::getOptions($itemtype);
197202
$table = $searchopt[$id]["table"];
198203
$field = $searchopt[$id]["field"];
199204

tests/fixtures/formcreator.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,27 @@
2626
-- -------------------------------------------------------------------------
2727
--
2828

29+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_formanswers` (
30+
`id` int unsigned NOT NULL AUTO_INCREMENT,
31+
`name` varchar(255) NOT NULL DEFAULT '',
32+
`entities_id` int unsigned NOT NULL DEFAULT '0',
33+
`is_recursive` tinyint(1) NOT NULL DEFAULT '0',
34+
`plugin_formcreator_forms_id` int unsigned NOT NULL DEFAULT '0',
35+
`requester_id` int unsigned NOT NULL DEFAULT '0',
36+
`users_id_validator` int unsigned NOT NULL DEFAULT '0' COMMENT 'User in charge of validation',
37+
`groups_id_validator` int unsigned NOT NULL DEFAULT '0' COMMENT 'Group in charge of validation',
38+
`request_date` timestamp NULL,
39+
`status` int(11) NOT NULL DEFAULT '101',
40+
`comment` mediumtext,
41+
PRIMARY KEY (`id`),
42+
INDEX `plugin_formcreator_forms_id` (`plugin_formcreator_forms_id`),
43+
INDEX `entities_id_is_recursive` (`entities_id`, `is_recursive`),
44+
INDEX `requester_id` (`requester_id`),
45+
INDEX `users_id_validator` (`users_id_validator`),
46+
INDEX `groups_id_validator` (`groups_id_validator`)
47+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
48+
49+
2950
DROP TABLE IF EXISTS `glpi_plugin_formcreator_categories`;
3051
CREATE TABLE `glpi_plugin_formcreator_categories` (
3152
`id` int unsigned NOT NULL AUTO_INCREMENT,

0 commit comments

Comments
 (0)