Skip to content

Commit

Permalink
fix: duplicate key value violates unique constraint error
Browse files Browse the repository at this point in the history
  • Loading branch information
maelgangloff committed Sep 9, 2024
1 parent e629651 commit 0e98b7d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Service/RDAPService.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,17 @@ public function registerDomain(string $fqdn): Domain

if (array_key_exists('nameservers', $res) && is_array($res['nameservers'])) {
$domain->getNameservers()->clear();
$this->em->persist($domain);

foreach ($res['nameservers'] as $rdapNameserver) {
$nameserver = $this->nameserverRepository->findOneBy([
'ldhName' => strtolower($rdapNameserver['ldhName']),
]);

$domainNS = $domain->getNameservers()->findFirst(fn (Nameserver $ns) => $ns->getLdhName() === $rdapNameserver['ldhName']);

Check failure on line 316 in src/Service/RDAPService.php

View workflow job for this annotation

GitHub Actions / symfony-tests

Parameter #1 $p of method Doctrine\Common\Collections\ReadableCollection<int,App\Entity\Nameserver>::findFirst() expects Closure(int, App\Entity\Nameserver): bool, Closure(App\Entity\Nameserver): bool given.

if (null !== $domainNS) {
$nameserver = $domainNS;
}
if (null === $nameserver) {
$nameserver = new Nameserver();
}
Expand Down

0 comments on commit 0e98b7d

Please sign in to comment.