Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Fix crash when injection model has no mandatory fields defined
- Fix models created on parent entities can't be used on child entites
- Fix responsible group injection payload normalization so group remains visible in GLPI after import

## [2.15.4] - 2026-03-16

Expand Down
28 changes: 19 additions & 9 deletions inc/commoninjectionlib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1688,16 +1688,26 @@ private function effectiveAddOrUpdate($injectionClass, $item, $values, $add = tr
$toinject[$key] = $value;
}

// handle new format for group type specification
// restricting to group_item relations only
if (($key === "groups_id_tech" || $key === "groups_id" || $key === "groups_id_normal") && $option['table'] == getTableForItemType(Group::class) && !empty($option) && isset($option['joinparams']['beforejoin']['table']) && $option['joinparams']['beforejoin']['table'] === getTableForItemType(Group_Item::class) && isset($option['joinparams']['beforejoin']['joinparams']['condition']['NEWTABLE.type'])) {
$group_type = $option['joinparams']['beforejoin']['joinparams']['condition']['NEWTABLE.type'];
// depending on the type, set the correct field (_groups_id_tech => array or _groups_id => array)
// and unset the old one (groups_id_tech => int or groups_id => int or groups_id_normal => int)
if ($group_type == Group_Item::GROUP_TYPE_TECH) {
$toinject["_groups_id_tech"] = [$value];
// Normalize group assignment fields to GLPI relation payload keys.
// Some search options do not expose a stable joinparams shape, but GLPI
// still expects _groups_id/_groups_id_tech arrays when saving equipment groups.
if (
in_array($key, ['groups_id_tech', 'groups_id', 'groups_id_normal'], true)
&& !empty($option)
&& isset($option['table'])
&& $option['table'] === getTableForItemType(Group::class)
) {
$normalized_value = $toinject[$key];
$group_type = null;
if (isset($option['joinparams']['beforejoin']['joinparams']['condition']['NEWTABLE.type'])) {
$group_type = $option['joinparams']['beforejoin']['joinparams']['condition']['NEWTABLE.type'];
}

// Keep explicit technical group semantics from key or metadata.
if ($key === 'groups_id_tech' || $group_type == Group_Item::GROUP_TYPE_TECH) {
$toinject['_groups_id_tech'] = [$normalized_value];
} else {
$toinject["_groups_id"] = [$value];
$toinject['_groups_id'] = [$normalized_value];
}
Comment thread
Neu-Maximilian marked this conversation as resolved.
unset($toinject[$key]);
}
Expand Down