Skip to content

Commit

Permalink
fix: avoid warnings from dns_get_record.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Thulin committed Nov 14, 2024
1 parent 53f1526 commit b5ac32c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions source/php/BrokenLinkRegistry/ClassifyLink/Classify.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,24 @@ private function tryGetHttpCodeByPostStatus(): ?int
*/
private function tryGetDnsRecord(): bool
{
static $dnsCache = [];
static $dnsCache = [];

if (!$this->config->checkIfDnsRespondsBeforeProbingUrl() || !function_exists('dns_get_record')) {
return true;
}
if (!$this->config->checkIfDnsRespondsBeforeProbingUrl() || !function_exists('dns_get_record')) {
return true;
}

try {
$domain = $this->getUrlDomain();

if (isset($dnsCache[$domain])) {
return $dnsCache[$domain];
}

return $dnsCache[$domain] = (bool) dns_get_record($domain, DNS_A) || (bool) dns_get_record($domain, DNS_CNAME);

} catch(\Exception $e) {
return true;
}
}

/**
Expand Down

0 comments on commit b5ac32c

Please sign in to comment.