Merge branch '350-validation_person_duplicate' into 'master'

Resolve "Erreur 500 lorsqu'un utilisateur fusionne deux dossiers d'usagers, et que les deux dossiers usagers sélectionnés sont les mêmes"

Closes #350

See merge request Chill-Projet/chill-bundles!788
This commit is contained in:
Julien Fastré 2025-02-03 21:04:28 +00:00
commit 7c79b65f48
3 changed files with 17 additions and 1 deletions

View File

@ -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

View File

@ -29,6 +29,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
use function count; use function count;
class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController 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 EventDispatcherInterface $eventDispatcher,
private readonly Security $security, private readonly Security $security,
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, 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')] #[\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(); $person2 = $form->get('person')->getData();
if (null === $person2) { 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(); $direction = $form->get('direction')->getData();

View File

@ -127,6 +127,7 @@ not-duplicate: Faux-positif
Switch to truefalse: Marquer comme faux-positif Switch to truefalse: Marquer comme faux-positif
Switch to duplicate: Marquer comme doublon Switch to duplicate: Marquer comme doublon
No duplicate candidates: Il n'y a pas de doublons détectés, ni de faux-positifs 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 # addresses part
address_street_address_1: Adresse ligne 1 address_street_address_1: Adresse ligne 1