From 124091893091cc9cdb5fdfdca5e333071c80e573 Mon Sep 17 00:00:00 2001 From: AdrienClairembault Date: Thu, 26 Dec 2024 15:39:36 +0100 Subject: [PATCH] Fix missing requester on default forms --- phpunit/functional/Glpi/Helpdesk/DefaultDataManagerTest.php | 6 ++++++ .../Destination/CommonITILField/AssociatedItemsField.php | 4 ++++ .../Form/Destination/CommonITILField/ITILActorField.php | 4 ++++ .../Form/Destination/CommonITILField/ValidationField.php | 4 ++++ 4 files changed, 18 insertions(+) diff --git a/phpunit/functional/Glpi/Helpdesk/DefaultDataManagerTest.php b/phpunit/functional/Glpi/Helpdesk/DefaultDataManagerTest.php index 4bd38d4d1b9..af44ccf74a4 100644 --- a/phpunit/functional/Glpi/Helpdesk/DefaultDataManagerTest.php +++ b/phpunit/functional/Glpi/Helpdesk/DefaultDataManagerTest.php @@ -209,6 +209,9 @@ public function testIncidentFormQuestions(): void [$computer->getID()], array_values($ticket->getLinkedItems()[Computer::class]) ); + $actors = $ticket->getActorsForType(CommonITILActor::REQUESTER); + $actor = current($actors); + $this->assertEquals(TU_USER, $actor['title']); } public function testRequestFormQuestions(): void @@ -301,6 +304,9 @@ public function testRequestFormQuestions(): void [$computer->getID()], array_values($ticket->getLinkedItems()[Computer::class]) ); + $actors = $ticket->getActorsForType(CommonITILActor::REQUESTER); + $actor = current($actors); + $this->assertEquals(TU_USER, $actor['title']); } public function testIncidentFormShouldBeAccessibleBySelfServiceUsers(): void diff --git a/src/Glpi/Form/Destination/CommonITILField/AssociatedItemsField.php b/src/Glpi/Form/Destination/CommonITILField/AssociatedItemsField.php index 4a485913fea..1d697bde4ca 100644 --- a/src/Glpi/Form/Destination/CommonITILField/AssociatedItemsField.php +++ b/src/Glpi/Form/Destination/CommonITILField/AssociatedItemsField.php @@ -206,6 +206,10 @@ public function prepareInput(array $input): array { $input = parent::prepareInput($input); + if (!isset($input[$this->getKey()][AssociatedItemsFieldConfig::STRATEGY])) { + return $input; + } + // Ensure that question_ids is an array if (!is_array($input[$this->getKey()][AssociatedItemsFieldConfig::SPECIFIC_QUESTION_IDS] ?? null)) { $input[$this->getKey()][AssociatedItemsFieldConfig::SPECIFIC_QUESTION_IDS] = null; diff --git a/src/Glpi/Form/Destination/CommonITILField/ITILActorField.php b/src/Glpi/Form/Destination/CommonITILField/ITILActorField.php index 66f8ff0deb2..07c09bdfc1a 100644 --- a/src/Glpi/Form/Destination/CommonITILField/ITILActorField.php +++ b/src/Glpi/Form/Destination/CommonITILField/ITILActorField.php @@ -140,6 +140,10 @@ public function prepareInput(array $input): array { $input = parent::prepareInput($input); + if (!isset($input[$this->getKey()][ITILActorFieldConfig::STRATEGY])) { + return $input; + } + // Ensure that itilactors_ids is an array if (!is_array($input[$this->getKey()][ITILActorFieldConfig::SPECIFIC_ITILACTORS_IDS] ?? null)) { $input[$this->getKey()][ITILActorFieldConfig::SPECIFIC_ITILACTORS_IDS] = null; diff --git a/src/Glpi/Form/Destination/CommonITILField/ValidationField.php b/src/Glpi/Form/Destination/CommonITILField/ValidationField.php index 9ca2fcc1627..73e5ab9b2c9 100644 --- a/src/Glpi/Form/Destination/CommonITILField/ValidationField.php +++ b/src/Glpi/Form/Destination/CommonITILField/ValidationField.php @@ -199,6 +199,10 @@ public function prepareInput(array $input): array { $input = parent::prepareInput($input); + if (!isset($input[$this->getKey()][ValidationFieldConfig::STRATEGY])) { + return $input; + } + // Ensure that question_ids is an array if (!is_array($input[$this->getKey()][ValidationFieldConfig::SPECIFIC_QUESTION_IDS] ?? null)) { $input[$this->getKey()][ValidationFieldConfig::SPECIFIC_QUESTION_IDS] = null;