From c3209a1ac1a719d4839897d47861484b5163b439 Mon Sep 17 00:00:00 2001 From: Lainow Date: Wed, 7 Oct 2026 12:12:30 +0200 Subject: [PATCH 1/4] Fix form submission error when 'Use technician group on ticket creation' is enabled --- inc/ticket.class.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/inc/ticket.class.php b/inc/ticket.class.php index 31ab26a8..bb172118 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -647,9 +647,18 @@ public static function assignUserGroup(Ticket $ticket) return false; } + // `_users_id_assign` may be either a single ID or an array of IDs + $users_id_assign = 0; + if (isset($ticket->input['_users_id_assign'])) { + $assigned_users = array_filter( + array_map('intval', (array) $ticket->input['_users_id_assign']), + static fn(int $id) => $id > 0, + ); + $users_id_assign = (int) reset($assigned_users); + } + if ( - isset($ticket->input['_users_id_assign']) - && $ticket->input['_users_id_assign'] > 0 + $users_id_assign > 0 && (!isset($ticket->input['_groups_id_assign']) || empty($ticket->input['_groups_id_assign'])) ) { @@ -658,7 +667,7 @@ public static function assignUserGroup(Ticket $ticket) $ticket->input['_groups_id_assign'] = PluginEscaladeUser::getTechnicianGroup( $ticket->input['entities_id'], - current($ticket->input['_users_id_assign']), + $users_id_assign, true, ); } else { @@ -666,7 +675,7 @@ public static function assignUserGroup(Ticket $ticket) $ticket->input['_groups_id_assign'] = PluginEscaladeUser::getTechnicianGroup( $ticket->input['entities_id'], - current($ticket->input['_users_id_assign']), + $users_id_assign, false, ); } From fb5a56aacb0a2e577e0a12c691359a08657b77dc Mon Sep 17 00:00:00 2001 From: Lainow Date: Wed, 7 Oct 2026 14:11:27 +0200 Subject: [PATCH 2/4] Add units tests --- tests/Units/TicketTest.php | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/Units/TicketTest.php b/tests/Units/TicketTest.php index 6170a1c7..7da1c048 100644 --- a/tests/Units/TicketTest.php +++ b/tests/Units/TicketTest.php @@ -1666,4 +1666,60 @@ public function testKeepNewAssignUsersFlagIsClearedWhenFollowUpNeverHappens() 'The keep-users flag must not survive past the request when the follow-up group add never happens', ); } + + /** + * When the technician is auto-assigned by the core from the ITIL category, + * `_users_id_assign` is a scalar ID (not an array): the technician group + * must still be assigned on ticket creation. + */ + public function testAssignUserGroupOnCreationWithTechnicianFromCategory() + { + $this->initConfig([ + 'use_assign_user_group' => 1, + 'use_assign_user_group_creation' => 1, + ]); + + $this->updateItem('Entity', 0, [ + 'auto_assign_mode' => Entity::AUTO_ASSIGN_CATEGORY_HARDWARE, + ]); + + $tech = new User(); + $tech->getFromDBbyName('tech'); + $this->assertGreaterThan(0, $tech->getID()); + + $group = $this->createItem('Group', [ + 'name' => 'Technician group', + 'entities_id' => 0, + 'is_recursive' => 1, + ]); + $this->createItem('Group_User', [ + 'users_id' => $tech->getID(), + 'groups_id' => $group->getID(), + ]); + + $itil_cat = $this->createItem('ITILCategory', [ + 'name' => 'Cat with technician', + 'users_id' => $tech->getID(), + 'entities_id' => 0, + ]); + + $ticket = $this->createItem('Ticket', [ + 'name' => 'Ticket without assigned technician', + 'content' => 'Content', + 'entities_id' => 0, + 'itilcategories_id' => $itil_cat->getID(), + ]); + $ticket_id = $ticket->getID(); + + $this->assertEquals( + 1, + countElementsInTable(Ticket_User::getTable(), ['tickets_id' => $ticket_id, 'type' => CommonITILActor::ASSIGN, 'users_id' => $tech->getID()]), + 'Technician from the category should be assigned', + ); + $this->assertEquals( + 1, + countElementsInTable(Group_Ticket::getTable(), ['tickets_id' => $ticket_id, 'type' => CommonITILActor::ASSIGN, 'groups_id' => $group->getID()]), + 'Technician group should be assigned', + ); + } } From f03c68ae08434e5380e51e2837654111b942c664 Mon Sep 17 00:00:00 2001 From: Lainow Date: Wed, 7 Oct 2026 15:00:50 +0200 Subject: [PATCH 3/4] Fix CI --- CHANGELOG.md | 1 + inc/ticket.class.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c579fcf3..05b3a07a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fix flaky escalation test on solve/reject-solution data sets - CI: fix Psalm cache directory, drop the stray `glpi-project/tools` composer dependency, declare a unique composer autoloader suffix +- Fix form submission error when 'Use technician group on ticket creation' is enabled ## [2.10.8] 2026-09-11 diff --git a/inc/ticket.class.php b/inc/ticket.class.php index bb172118..fc64f359 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -651,7 +651,7 @@ public static function assignUserGroup(Ticket $ticket) $users_id_assign = 0; if (isset($ticket->input['_users_id_assign'])) { $assigned_users = array_filter( - array_map('intval', (array) $ticket->input['_users_id_assign']), + array_map(intval(...), (array) $ticket->input['_users_id_assign']), static fn(int $id) => $id > 0, ); $users_id_assign = (int) reset($assigned_users); From 0444ccdb6d0fef4f5b4c733839bbb8b1d04f9a30 Mon Sep 17 00:00:00 2001 From: Samuel Launay <107540223+Lainow@users.noreply.github.com> Date: Thu, 22 Oct 2026 16:06:56 +0200 Subject: [PATCH 4/4] Update inc/ticket.class.php Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com> --- inc/ticket.class.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/inc/ticket.class.php b/inc/ticket.class.php index ed12688a..77059097 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -630,14 +630,7 @@ public static function assignUserGroup(Ticket $ticket) } // `_users_id_assign` may be either a single ID or an array of IDs - $users_id_assign = 0; - if (isset($ticket->input['_users_id_assign'])) { - $assigned_users = array_filter( - array_map(intval(...), (array) $ticket->input['_users_id_assign']), - static fn(int $id) => $id > 0, - ); - $users_id_assign = (int) reset($assigned_users); - } + $users_id_assign = (int) current(array_filter((array) ($ticket->input['_users_id_assign'] ?? []))); if ( $users_id_assign > 0