From 5d86ec34f3fd652bd1e3ab39ab93412a89dc105e Mon Sep 17 00:00:00 2001 From: mbressy Date: Wed, 8 Apr 2026 08:04:55 +0000 Subject: [PATCH 1/5] fix: handle group assignment on uninstall templates --- inc/uninstall.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/uninstall.class.php b/inc/uninstall.class.php index 2757eb0..53cf750 100644 --- a/inc/uninstall.class.php +++ b/inc/uninstall.class.php @@ -215,7 +215,8 @@ private static function doOneUninstall(PluginUninstallModel $model, Transfer $tr } } - if ($item->isField('groups_id')) { + $can_update_groups = $item->isField('groups_id') || method_exists($item, 'prepareGroupFields'); + if ($can_update_groups) { $nbgroup = countElementsInTableForEntity( "glpi_groups", $entity, From 1a2fc2d4f5666a940b833b78a978ec11ecb4fdee Mon Sep 17 00:00:00 2001 From: mbressy Date: Wed, 8 Apr 2026 12:28:36 +0000 Subject: [PATCH 2/5] use AssignableItemInterface --- inc/uninstall.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/inc/uninstall.class.php b/inc/uninstall.class.php index 53cf750..00d3255 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,8 +216,10 @@ private static function doOneUninstall(PluginUninstallModel $model, Transfer $tr } } - $can_update_groups = $item->isField('groups_id') || method_exists($item, 'prepareGroupFields'); - if ($can_update_groups) { + if ( + $item->isField('groups_id') + || ($item instanceof AssignableItemInterface) + ) { $nbgroup = countElementsInTableForEntity( "glpi_groups", $entity, From 39a5006bee5c0c3fd0f6079748e322577b72099e Mon Sep 17 00:00:00 2001 From: mbressy Date: Mon, 13 Apr 2026 13:30:21 +0000 Subject: [PATCH 3/5] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92a7402..dd34e21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fix SQL errors when uninstalling or replacing peripheral assets - Fix locales encoding - Fixed the display of “Item's Lifecycle” in the breadcrumb trail +- Fix group assignment when applying uninstall templates on assignable items ## [2.10.3] - 2025-11-25 From 553571e5df1054189357f55e1a7376a87283b500 Mon Sep 17 00:00:00 2001 From: mbressy Date: Fri, 28 Aug 2026 13:24:59 +0000 Subject: [PATCH 4/5] fix CHANGELOG placement --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd34e21..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 @@ -18,7 +19,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fix SQL errors when uninstalling or replacing peripheral assets - Fix locales encoding - Fixed the display of “Item's Lifecycle” in the breadcrumb trail -- Fix group assignment when applying uninstall templates on assignable items ## [2.10.3] - 2025-11-25 From e2d9e1f791b5ca2168c8bbf9e666b4221b326920 Mon Sep 17 00:00:00 2001 From: mbressy Date: Fri, 28 Aug 2026 13:33:23 +0000 Subject: [PATCH 5/5] set assignable item group as array --- inc/uninstall.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/inc/uninstall.class.php b/inc/uninstall.class.php index 00d3255..ba6f34c 100644 --- a/inc/uninstall.class.php +++ b/inc/uninstall.class.php @@ -230,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"]; } }