Skip to content
Merged
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ 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
- Simplify group reassignment to a single actor diff, relying on GLPI core's status preservation on simultaneous actor removal/addition


## [2.10.8] 2026-09-11

### Fixed
Expand Down
10 changes: 6 additions & 4 deletions inc/ticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,11 @@ 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 = (int) current(array_filter((array) ($ticket->input['_users_id_assign'] ?? [])));

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']))
) {
Expand All @@ -640,15 +642,15 @@ 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 {
// All groups
$ticket->input['_groups_id_assign']
= PluginEscaladeUser::getTechnicianGroup(
$ticket->input['entities_id'],
current($ticket->input['_users_id_assign']),
$users_id_assign,
false,
);
}
Expand Down
56 changes: 56 additions & 0 deletions tests/Units/TicketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1724,4 +1724,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',
);
}
}
Loading