diff --git a/CHANGELOG.md b/CHANGELOG.md index c579fcf3..61c640bd 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 ticket status config being reset to default after each plugin update ## [2.10.8] 2026-09-11 diff --git a/hook.php b/hook.php index 752848fe..e96c1d84 100644 --- a/hook.php +++ b/hook.php @@ -176,8 +176,14 @@ function plugin_escalade_install() $DB->doQuery($query); } - // Update for 0.84 status - if ($DB->tableExists('glpi_plugin_escalade_configs')) { + // Update for 0.84 status (only while `ticket_last_status` is still a VARCHAR, i.e. not yet migrated) + if ( + $DB->tableExists('glpi_plugin_escalade_configs') + && !str_starts_with( + strtolower($DB->listFields('glpi_plugin_escalade_configs')['ticket_last_status']['Type'] ?? 'int'), + 'int', + ) + ) { foreach ($DB->request(['FROM' => "glpi_plugin_escalade_configs"]) as $data) { $status = match ($data['ticket_last_status']) { 'solved' => Ticket::SOLVED, diff --git a/tests/Units/GroupEscalationTest.php b/tests/Units/GroupEscalationTest.php index a838d9c6..ac1f5a91 100644 --- a/tests/Units/GroupEscalationTest.php +++ b/tests/Units/GroupEscalationTest.php @@ -949,10 +949,7 @@ public function testHistory() $this->assertEquals(1, count($history->find(['tickets_id' => $ticket->getID(), 'groups_id' => $group1->getID()]))); } - /** - * Test that the standard target "Group in charge of the ticket" - * sends notifications to users of both groups (old and new) during an escalation - */ + // The "Group in charge of the ticket" target only notifies the newly assigned group on escalation. public function testStandardGroupNotification() { global $CFG_GLPI, $DB; @@ -1046,11 +1043,10 @@ public function testStandardGroupNotification() $notification_recipients[] = $notif['recipient']; } - // Check that users from both groups received notifications + // Only the new group's users should be notified; the old group was removed. $group1_user_emails = [$this->getItemEmail($user1), $this->getItemEmail($user2)]; $group2_user_emails = [$this->getItemEmail($user3), $this->getItemEmail($user4)]; - // At least one user from each group should have received a notification $group1_notified = false; $group2_notified = false; @@ -1068,7 +1064,7 @@ public function testStandardGroupNotification() } } - $this->assertTrue($group1_notified, "No user from the original group received a notification"); + $this->assertFalse($group1_notified, "A user from the removed group should not receive a notification"); $this->assertTrue($group2_notified, "No user from the new group received a notification"); } diff --git a/tests/Units/TaskMessageTest.php b/tests/Units/TaskMessageTest.php index 367e7574..1a1d3b3f 100644 --- a/tests/Units/TaskMessageTest.php +++ b/tests/Units/TaskMessageTest.php @@ -34,6 +34,7 @@ use Group_Ticket; use PHPUnit\Framework\Attributes\DataProvider; use Plugin; +use PluginEscaladeTicket; use Ticket; use Ticket_User; use TicketTask; @@ -193,6 +194,8 @@ public static function taskGroupEscalationProvider() #[DataProvider('taskGroupEscalationProvider')] public function testTaskGroupEscalation(array $conf) { + // Status must stay managed by core, otherwise the ticket status change interferes with the solve/reject flow + $conf['ticket_last_status'] = PluginEscaladeTicket::MANAGED_BY_CORE; $this->initConfig($conf); $ticket = $this->createItem('Ticket', [