Skip to content

Commit

Permalink
fix: prevent undefined array key exception in DuplicationSaveHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongerig committed May 16, 2024
1 parent 64d3928 commit ec5bb84
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ public function __construct(private readonly DuplicateServiceInterface $duplicat
*/
public function preSave(Concrete $object, array $options): void
{
$result = $this->duplicateService->findDuplicates($object, $options['group'] ? [$options['group']] : null);
$groups = isset($options['group']) ? [$options['group']] : null;
$result = $this->duplicateService->findDuplicates($object, $groups);

if (\count($result) > 0) {
$duplicatesException = new DuplicatesException(\sprintf('Duplicates of Object %s found', $object->getClassName()));
$duplicatesException = new DuplicatesException(
\sprintf('Duplicates of Object %s found', $object->getClassName())
);
$duplicatesException->setDuplicates($result);

throw $duplicatesException;
Expand Down

0 comments on commit ec5bb84

Please sign in to comment.