From b8f25bcd45f6846e2cb79553b95d66cc39d4c576 Mon Sep 17 00:00:00 2001 From: LenaertsJ Date: Mon, 3 Feb 2025 21:04:27 +0000 Subject: [PATCH] =?UTF-8?q?Resolve=20"Erreur=20500=20lorsqu'un=20utilisate?= =?UTF-8?q?ur=20fusionne=20deux=20dossiers=20d'usagers,=20et=20que=20les?= =?UTF-8?q?=20deux=20dossiers=20usagers=20s=C3=A9lectionn=C3=A9s=20sont=20?= =?UTF-8?q?les=20m=C3=AAmes"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changes/unreleased/Fixed-20250128-130242.yaml | 6 ++++++ .../Controller/PersonDuplicateController.php | 11 ++++++++++- .../ChillPersonBundle/translations/messages.fr.yml | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Fixed-20250128-130242.yaml diff --git a/.changes/unreleased/Fixed-20250128-130242.yaml b/.changes/unreleased/Fixed-20250128-130242.yaml new file mode 100644 index 000000000..bd03e44b4 --- /dev/null +++ b/.changes/unreleased/Fixed-20250128-130242.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Add validation error to manual selection of person in PersonDuplicateController +time: 2025-01-28T13:02:42.369442185+01:00 +custom: + Issue: "350" + SchemaChange: No schema change diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php index b11390a46..348a3495d 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php @@ -29,6 +29,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\Security\Core\Security; +use Symfony\Contracts\Translation\TranslatorInterface; use function count; class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController @@ -40,6 +41,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll private readonly EventDispatcherInterface $eventDispatcher, private readonly Security $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, + private readonly TranslatorInterface $translator, ) {} #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person1_id}/duplicate/{person2_id}/confirm', name: 'chill_person_duplicate_confirm')] @@ -125,7 +127,14 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll $person2 = $form->get('person')->getData(); if (null === $person2) { - throw $this->createNotFoundException("Person with id {$person2->getId}() not".' found on this server'); + throw $this->createNotFoundException('Person not found on this server'); + } + + // Validation: Ensure person1 is not the same as person2 + if ($person->getId() === $person2->getId()) { + $this->addFlash('error', $this->translator->trans('Person1 cannot be the same as Person2')); + + return $this->redirectToRoute('chill_person_duplicate_view', ['person_id' => $person2->getId()]); } $direction = $form->get('direction')->getData(); diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 6b3c5cd0e..dd4c9c3ba 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -127,6 +127,7 @@ not-duplicate: Faux-positif Switch to truefalse: Marquer comme faux-positif Switch to duplicate: Marquer comme doublon No duplicate candidates: Il n'y a pas de doublons détectés, ni de faux-positifs +Person1 cannot be the same as Person2: La personne que vous sélectionnez ne peut pas être la même que celle de ce dossier. # addresses part address_street_address_1: Adresse ligne 1