diff --git a/CHANGELOG.md b/CHANGELOG.md index 92a7402..b5edba0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Fix uninstall/replace actions processing items without checking item type or user rights on the item +- Fix group assignment when applying uninstall templates on assignable items ## [2.10.4] - 2026-08-04 diff --git a/inc/uninstall.class.php b/inc/uninstall.class.php index 2757eb0..ba6f34c 100644 --- a/inc/uninstall.class.php +++ b/inc/uninstall.class.php @@ -29,6 +29,7 @@ */ use Glpi\Asset\Asset_PeripheralAsset; +use Glpi\Features\AssignableItemInterface; use function Safe\preg_grep; @@ -215,7 +216,10 @@ private static function doOneUninstall(PluginUninstallModel $model, Transfer $tr } } - if ($item->isField('groups_id')) { + if ( + $item->isField('groups_id') + || ($item instanceof AssignableItemInterface) + ) { $nbgroup = countElementsInTableForEntity( "glpi_groups", $entity, @@ -226,7 +230,10 @@ private static function doOneUninstall(PluginUninstallModel $model, Transfer $tr && ($nbgroup == 1 || $model->fields["groups_id"] == 0) ) { // If a new group is defined and if the group is accessible in the object's entity - $fields["groups_id"] = $model->fields["groups_id"]; + // Assignable items store the group in `glpi_groups_items`, so `groups_id` must be an array (0 is filtered out, clearing the group) + $fields["groups_id"] = $item instanceof AssignableItemInterface + ? [$model->fields["groups_id"]] + : $model->fields["groups_id"]; } }