From be3b9f0f568cc8dec7025b19b80020fa037ee43d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 26 Sep 2025 15:03:02 +0200 Subject: [PATCH] Fix issue in PersonIdentifierDataMapper: find the PersonIdentifier against his definition --- src/Bundle/ChillPersonBundle/Controller/PersonController.php | 2 +- .../Form/DataMapper/PersonIdentifiersDataMapper.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index 4698373f1..f902118ef 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -279,7 +279,7 @@ final class PersonController extends AbstractController private function lastPostDataBuildHash(Form $form, Request $request): string { $fields = []; - $ignoredFields = ['form_status', '_token']; + $ignoredFields = ['form_status', '_token', 'identifiers']; foreach ($request->request->all()[$form->getName()] as $field => $value) { if (\in_array($field, $ignoredFields, true)) { diff --git a/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonIdentifiersDataMapper.php b/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonIdentifiersDataMapper.php index eea151865..f3bcfe1d5 100644 --- a/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonIdentifiersDataMapper.php +++ b/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonIdentifiersDataMapper.php @@ -39,7 +39,7 @@ final readonly class PersonIdentifiersDataMapper implements DataMapperInterface continue; } $form = $formsByKey['identifier_'.$worker->getDefinition()->getId()]; - $identifier = $viewData->findFirst(fn (int $key, PersonIdentifier $identifier) => $worker->getDefinition()->getId() === $identifier->getId()); + $identifier = $viewData->findFirst(fn (int $key, PersonIdentifier $identifier) => $worker->getDefinition() === $identifier->getDefinition()); if (null === $identifier) { $identifier = new PersonIdentifier($worker->getDefinition()); } @@ -55,7 +55,7 @@ final readonly class PersonIdentifiersDataMapper implements DataMapperInterface foreach ($forms as $name => $form) { $identifierId = (int) substr((string) $name, 11); - $identifier = $viewData->findFirst(fn (int $key, PersonIdentifier $identifier) => $identifier->getId() === $identifierId); + $identifier = $viewData->findFirst(fn (int $key, PersonIdentifier $identifier) => $identifier->getDefinition()->getId() === $identifierId); $definition = $this->identifierDefinitionRepository->find($identifierId); if (null === $identifier) { $identifier = new PersonIdentifier($definition);